some changes

This commit is contained in:
Evert Prants 2022-03-07 22:05:21 +02:00
parent f8640e40d1
commit 071b43b295
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 18 additions and 12 deletions

View File

@ -220,7 +220,7 @@ export const authorization = wrap(async (req, res) => {
data = await oauth2.model.jwt.issueIdToken( data = await oauth2.model.jwt.issueIdToken(
user, user,
scope, scope,
resObj.access_token as string | undefined req.query.nonce as string | undefined
); );
resObj = { resObj = {

View File

@ -116,11 +116,7 @@ export async function authorizationCode(
); );
try { try {
respObj.id_token = await oauth2.model.jwt.issueIdToken( respObj.id_token = await oauth2.model.jwt.issueIdToken(user, cleanScope);
user,
cleanScope,
respObj.access_token
);
} catch (err) { } catch (err) {
oauth2.logger.error(err); oauth2.logger.error(err);
throw new ServerError('Failed to issue an ID token'); throw new ServerError('Failed to issue an ID token');

View File

@ -316,17 +316,15 @@ export interface OAuth2UserAdapter {
export interface JWTAdapter { export interface JWTAdapter {
/** /**
* Issue a new ID token for user. * Issue a new ID token for user.
* @param user User data object obtained from the User adapter, must implement `OAuth2User` interface.
* @param scope String-list of scopes (usually used to determine the claims)
* @param nonce Cryptographic key passed to the authentication request, *must* be passed along as a claim.
*/ */
issueIdToken: ( issueIdToken: (
user: OAuth2User, user: OAuth2User,
scope: string[], scope: string[],
accessToken?: string nonce?: string
) => Promise<string>; ) => Promise<string>;
/**
* Validate an ID token
*/
validateIdToken: (idToken: string) => Promise<boolean>;
} }
/** /**
@ -357,7 +355,19 @@ export interface OAuth2AdapterModel {
* OAuth2 adapter * OAuth2 adapter
*/ */
export interface OAuth2 { export interface OAuth2 {
/**
* Adapter for the OAuth2 data models.
*/
model: OAuth2AdapterModel; model: OAuth2AdapterModel;
/**
* Logger wrapper, use a logger of your choice by calling `logger.setLogger(...)`.
* To disable, use `logger.setLogLevel('none')`.
*/
logger: OAuth2Logger; logger: OAuth2Logger;
/**
* Render function for the OAuth2 decision page
*/
decision: RenderOAuth2Decision; decision: RenderOAuth2Decision;
} }