Skip to content
Open
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
15 changes: 14 additions & 1 deletion models/model_oauth_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,21 @@ function generateJwtToken(token, client, identity) {
if (token.accessTokenExpiresAt) {
options.expiresIn = config_oauth2.access_token_lifetime;
}

// Add the iss claim
response.iss = config.host + '/idm/applications/' + client.id;

// If the default algorithm (HS256) is chosen, client secret is used to sign the JWT.
let secretOrPrivateKey = client.jwt_secret;
// Otherwise, if RS256 is chosen, retrieve the application private key and use it to sign the JWT.
if (config_oidc.jwt_algorithm === 'RS256') {
const privateKey = readKeyIdToken(client);
options.algorithm = config_oidc.jwt_algorithm;
options.keyid = client.id;
secretOrPrivateKey = privateKey;
}

token.accessToken = jsonwebtoken.sign(response, client.jwt_secret, options);
token.accessToken = jsonwebtoken.sign(response, secretOrPrivateKey, options);
return storeToken(token, client, identity, true);
})
.catch(function (error) {
Expand Down
Loading