chronograf/etc/oauth2-server-mock
k3yi0 39e53012b7 chore: remove wait, increase redirect delay, add additional logout 2022-05-09 15:55:38 +02:00
..
src chore: remove wait, increase redirect delay, add additional logout 2022-05-09 15:55:38 +02:00
LICENSE chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00
README.md chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00
env.sh chore: add Oauth2 mock server 2022-05-09 15:55:37 +02:00
oauth-for-chronograf.sh chore: add oauth2 login auto-redirect and adjust tests according to it 2022-05-09 15:55:37 +02:00
package-lock.json chore: add Oauth2 mock server 2022-05-09 15:55:37 +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 (npm,yarn,pnmp):

npm install

Configure

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

Start

npm run 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" }
}'