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

[KEYCLOAK-17112] Added realm key algorithm as a config option #274

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions middleware/auth-utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ Config.prototype.configure = function configure (config) {
* @type {Boolean}
*/
this.verifyTokenAudience = resolveValue(config['verify-token-audience'] || config.verifyTokenAudience || false);
/**
* Algorithm used for the key
* Default: RSA-SHA256
* @type {String}
*/
this.publicKeyAlgorithm = resolveValue(config['realm-public-key-algorithm'] || config.realmPublicKeyAlgorithm || 'RSA-SHA256');
};

module.exports = Config;
3 changes: 2 additions & 1 deletion middleware/auth-utils/grant-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function GrantManager (config) {
this.notBefore = 0;
this.rotation = new Rotation(config);
this.verifyTokenAudience = config.verifyTokenAudience;
this.publicKeyAlgorithm = config.publicKeyAlgorithm;
}

/**
Expand Down Expand Up @@ -440,7 +441,7 @@ GrantManager.prototype.validateToken = function validateToken (token, expectedTy
reject(new Error('invalid token (wrong audience)'));
}
}
const verify = crypto.createVerify('RSA-SHA256');
const verify = crypto.createVerify(this.publicKeyAlgorithm);
// if public key has been supplied use it to validate token
if (this.publicKey) {
try {
Expand Down