A simple app for testing the cogs involved with SSO integration. Simply replies back with the Bearer you send.
Thanks for the thoughts and influence from r4vi/fakesso
Name | Description |
---|---|
MOCK_SSO_PORT | The applications port, defaults to 8080 |
MOCK_SSO_USERNAME | The SSO username to create an SSO token for. |
MOCK_SSO_USER_EMAIL | An optional value for the SSO user email. |
MOCK_SSO_USER_CONTACT_EMAIL | An optional value for the SSO user contact email. |
MOCK_SSO_EMAIL_USER_ID | The required SSO email user id. |
MOCK_SSO_SCOPE | The required introspect scope |
MOCK_SSO_CODE | The code passed to the source application |
MOCK_SSO_TOKEN | The required user token for optional validation |
MOCK_SSO_VALIDATE_TOKEN | Whether to validate the token for the user |
Recommended setup
To install multiple versions of Node.js, you may find it easier to use a node version manager
To install dependencies
$ npm i
To start the application
$ npm start
To run tests
$ npm test
To run linting
$ npm run lint
Introspect uses the rfc7662 specification.
A POST
request to /o/introspect
will reply back with a 200 and the following the response
{
"active": true,
"exp": 2524608000,
"scope": <MOCK_SSO_SCOPE>
}
If you wish to create an SSO token you can provide the username that you wish to associate the token with via the
environment variable MOCK_SSO_USERNAME
. This will then return the following response:
{
"active": true,
"exp": 2524608000,
"scope": <MOCK_SSO_SCOPE>,
"username": <MOCK_SSO_USERNAME>,
"email_user_id": <MOCK_SSO_EMAIL_USER_ID>,
}
A GET
request to /o/authorize
will redirect you back to redirect_uri?state=<state>&code=<code>
Name | Description |
---|---|
redirect_uri |
Your applications OAuth callback url |
state |
Your applications stateId |
code |
The token you wish to be sent back from SSO. Alternatively, use the MOCK_SSO_CODE environment variable |
A POST
request to /o/token
will reply with you back to you with a JSON response of
{
access_token: <code>,
token_type: 'Bearer',
}
A GET
request to /api/v1/user/me/
will reply back to you with:
A statusCode
of 400 and a JSON response of
{ error: 'invalid_request' }
A statusCode
of 200 and a JSON response of
{
email: <email>,
email_user_id: <string>,
user_id: <id>,
first_name: <string>,
last_name: <string>,
related_emails: [],
groups: [],
permitted_applications: [
{
key: <key>,
url: <url>,
name: <string>
},
...
],
access_profiles: [
<string>,
...
]
}
A GET
request to /api/v1/user/search/
will reply back to you with a statusCode
of 200 and a JSON response of a list of all users, filtered so that either first_name
or last_name
includes the search string passed with as the autocomplete
parameter.
[
{
"user_id": <id>,
"first_name": <string>,
"last_name": <string>,
"email": <email>,
"email_user_id": <string>
}
...
]
Name | Description |
---|---|
autocomplete |
The search string you wish to use to find a user |
A GET
request to /api/v1/user/instrospect/
will reply back to you with:
A statusCode
of 404
A JSON response containing information about the matching user
{
"user_id": <id>,
"first_name": <string>,
"last_name": <string>,
"email": <email>,
"email_user_id": <string>
}
A GET
request to /healthcheck
will reply with you back to you with a 200 and "OK"
Name | Description |
---|---|
code |
The token you wish to be sent back from SSO |
To build a docker image
$ docker build -t sso-mock .
To run locally
$ docker run -p 8080:8080 -d sso-mock
To run this project under docker-compose, do the following:
-
Create a
.env
filecp sample.env .env
-
Set the environment variables within your
.env
file as appropriate. -
Run
docker-compose up
There is also a docker automated build setup for this repository. This can be found at https://hub.docker.com/r/ukti/mock-sso