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(
user,
scope,
resObj.access_token as string | undefined
req.query.nonce as string | undefined
);
resObj = {

View File

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

View File

@ -316,17 +316,15 @@ export interface OAuth2UserAdapter {
export interface JWTAdapter {
/**
* 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: (
user: OAuth2User,
scope: string[],
accessToken?: string
nonce?: string
) => Promise<string>;
/**
* Validate an ID token
*/
validateIdToken: (idToken: string) => Promise<boolean>;
}
/**
@ -357,7 +355,19 @@ export interface OAuth2AdapterModel {
* OAuth2 adapter
*/
export interface OAuth2 {
/**
* Adapter for the OAuth2 data models.
*/
model: OAuth2AdapterModel;
/**
* Logger wrapper, use a logger of your choice by calling `logger.setLogger(...)`.
* To disable, use `logger.setLogLevel('none')`.
*/
logger: OAuth2Logger;
/**
* Render function for the OAuth2 decision page
*/
decision: RenderOAuth2Decision;
}