first commit
This commit is contained in:
parent
0cebc620aa
commit
159face27e
@ -46,13 +46,15 @@ export function getOIDCClient() {
|
|||||||
export function getAuthorizationUrl(req) {
|
export function getAuthorizationUrl(req) {
|
||||||
const client = getOIDCClient();
|
const client = getOIDCClient();
|
||||||
const nonce = Math.random().toString(36).substring(7);
|
const nonce = Math.random().toString(36).substring(7);
|
||||||
|
const state = Math.random().toString(36).substring(7);
|
||||||
req.session.nonce = nonce;
|
req.session.nonce = nonce;
|
||||||
|
req.session.state = state;
|
||||||
|
|
||||||
return client.authorizationUrl({
|
return client.authorizationUrl({
|
||||||
scope: 'openid profile email',
|
scope: 'openid profile email',
|
||||||
response_mode: 'form_post',
|
response_mode: 'form_post',
|
||||||
nonce,
|
nonce,
|
||||||
state: Math.random().toString(36).substring(7),
|
state,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ export async function handleCallback(req) {
|
|||||||
|
|
||||||
const tokenSet = await client.callback(config.oidc.redirectUri, params, {
|
const tokenSet = await client.callback(config.oidc.redirectUri, params, {
|
||||||
nonce: req.session.nonce,
|
nonce: req.session.nonce,
|
||||||
|
state: req.session.state,
|
||||||
});
|
});
|
||||||
|
|
||||||
const userInfo = await client.userinfo(tokenSet);
|
const userInfo = await client.userinfo(tokenSet);
|
||||||
|
|||||||
@ -54,6 +54,7 @@ async function initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Middleware
|
// Middleware
|
||||||
|
app.trust('proxy');
|
||||||
app.use(requestLogger);
|
app.use(requestLogger);
|
||||||
app.use(securityHeaders);
|
app.use(securityHeaders);
|
||||||
app.use(bodyParser.json({ limit: '10mb' }));
|
app.use(bodyParser.json({ limit: '10mb' }));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user