chronograf/etc/oauth2-server-mock
k3yi0 4005254a67 chore(oauth-mock): remove async from before function 2022-06-06 09:14:49 +02:00
..
src chore(oauth-mock): remove async from before function 2022-06-06 09:14:49 +02:00
README.md chore: OAuth2 Server mock remove License and package-lock, adjust README 2022-05-09 15:55:38 +02:00
env.sh chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00
oauth-for-chronograf.sh chore: adjust comment 2022-05-09 15:55:38 +02:00
package.json chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00
yarn.lock chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00

README.md

oauth2-server-mock

This repository contains a mock OAuth2 Authorization Server with Authorization Code Grant flow and OpenID UserInfo endpoint. It is primarily intended for testing, it always authorizes a pre-configured user that can be changed at runtime.

Install

Prerequisites: node.js 14 or newer

Install required dependencies using your favorite package manager yarn:

yarn

Configure

Modify ./env.sh and run source env.sh to setup initial configuration of the OAuth2 Mock Server.

Start

yarn start

Initial configuration is printed to console as well as the URL where the server is listening for requests.

Chronograf Setup

Chronograf can use this OAuth2 Mock server as a generic OAuth2 authentication provider, several environment variables must be set before starting chronograf. These variables are shown in ./oauth-for-chronograf.sh.

Change OAuth2 redirect or authorized user at runtime

The running OAuth2 Mock server exposes a simple UI that let you change name/email of the authorized user, and a redirect URL after authorization. This page is by default accessible at http://localhost:8087/ .

Alternatively a simple HTTP POST message can be sent to change the config:

curl -X POST http://localhost:8087/config -H 'Content-Type: application/json' -d '{
  "redirect_uri": "http://whatever.you.like/callback",
  "userinfo": { "name": "fred doe", "email": "fred.doe@fake.net" }
}'