Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/openid/not-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ export const startAuth302 = (deps) => (config) => (auth = {}) => (req, res) => {
disableNonce,
loginHint,
maxAge,
prompt,
scope,
} = config;

const nonce = disableNonce ? undefined : nonceGenerator();
const state = stateGenerator();

const authorizationUrl = authorizationUrlSupplier({
id_token_hint: req.session?.openId?.tokenSet?.id_token,
login_hint: loginHint?.enable ? req.session.openId?.claims?.[loginHint.claim] : undefined,
max_age: maxAge ?? undefined,
nonce,
Expand Down
20 changes: 20 additions & 0 deletions src/openid/not-authenticated.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,26 @@ describe('startAuth302', () => {
return deps.authorizationUrlSupplier;
}

test('should set `id_token_hint` when ID token available in existing session', async () => {
const ID_TOKEN = 'xxx.yyy.zzz';

const session = {
openId: {
tokenSet: {
id_token: ID_TOKEN
}
}
};
const authorizationUrlSupplier = await testAuthorizationUrl(options)()(session);

expect(authorizationUrlSupplier).toHaveBeenCalledWith({
id_token_hint: ID_TOKEN,
nonce: NONCE,
scope: options.scope,
state: STATE,
});
});

test('should populate `login_hint` when enabled with claim', async () => {
const config = {
...options,
Expand Down