Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow additional claims in access token #160

Merged
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
4 changes: 3 additions & 1 deletion packages/issuer/lib/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ export interface ITokenEndpointOpts {

export const generateAccessToken = async (
opts: Required<Pick<ITokenEndpointOpts, 'accessTokenSignerCallback' | 'tokenExpiresIn' | 'accessTokenIssuer'>> & {
additionalClaims?: Record<string, unknown>
preAuthorizedCode?: string
alg?: Alg
dPoPJwk?: JWK
},
): Promise<string> => {
const { dPoPJwk, accessTokenIssuer, alg, accessTokenSignerCallback, tokenExpiresIn, preAuthorizedCode } = opts
const { dPoPJwk, accessTokenIssuer, alg, accessTokenSignerCallback, tokenExpiresIn, preAuthorizedCode, additionalClaims } = opts
// JWT uses seconds for iat and exp
const iat = new Date().getTime() / 1000
const exp = iat + tokenExpiresIn
Expand All @@ -63,6 +64,7 @@ export const generateAccessToken = async (
// evaluation process is performed for bearer tokens to prevent downgraded usage of a DPoP-bound access token.
// Specifically, such a protected resource MUST reject a DPoP-bound access token received as a bearer token per [RFC6750].
token_type: dPoPJwk ? 'DPoP' : 'Bearer',
...additionalClaims,
},
}
return await accessTokenSignerCallback(jwt)
Expand Down
Loading