A simple package for a single sing-on (SSO) server
npm install sso-oauth2-server
npm-template
A simple server package for npm based on https://github.com/ankur-anand/simple-sso
index.js
``js
import SsoAuth2Server from '../SsoAuth2Server';
import Logger from '../Logger';
import {Connector, UrlHelper} from 'studip-api';
const STUDIP_AUTH_METHOD = async (body, client_id, scope, query) => {
Logger.log('Authentification: start');
const username = body.username;
const password = body.password;
//auth or throw error
return user;
};
const requiredLoginParams = {
username: 'string',
password: 'password',
};
const redirectMode = true;
const port = 3010;
const route = '/
const sessionSecret = 'keyboard cat';
const jwtSecret = 'MySuperSecret';
const ssoServer = new SsoAuth2Server(
redirectMode,
port,
route,
sessionSecret,
jwtSecret,
STUDIP_AUTH_METHOD,
requiredLoginParams
);
ssoServer.registerService(
'https://
'
'
);
ssoServer.start();
`
You can always see your registered Routes by calling:
`js`
ssoServer.getAllRegisteredRoutes();
By default the routes will be:
``
LOGIN: localhost/
AUTH_PARAMS: localhost/
AUTH_PARAMS: localhost/
PROFILE: localhost/
A client can now authentificate.
1. Get informations about needed auth Params
`
curl http://yourSSoAuth2ServerDomain:3010/customSubroute/authParams
-->
{
params: {
username: 'string',
password: 'password',
}
}
`
2. Your client know knows what to send as body
`js``
let body = {username: 'me', password: 'mycat'};
let url = 'http://yourSSoAuth2ServerDomain:3010/customSubroute/login?';
url += 'client_id=sso_consumer&';
url += 'redirect_uri=
url += 'response_type=code&';
url += 'scope=email firstname lastname&';
url += 'state=
axios.post(url, body);
3. Your client
The FireboltCasters