Skip to content

Commit

Permalink
Merge pull request #32 from sightsoundtheatres/master
Browse files Browse the repository at this point in the history
Fix /auth replace
  • Loading branch information
vzakharchenko committed Apr 22, 2021
2 parents 998cce4 + 40905df commit e4e6d6d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/keycloakAuthorizer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
const jsonwebtoken = require('jsonwebtoken');

const KeyCloakCerts = require('get-keycloak-public-key');
const { getKeycloakUrl } = require('./utils/restCalls');
const { getKeycloakUrl, getUrl } = require('./utils/restCalls');
const { enforce } = require('./umaConfiguration');
const { commonOptions } = require('./utils/optionsUtils');

async function getKeyFromKeycloak(options, kid) {
let publicKey = await options.cache.get('publicKey', kid);
if (!publicKey) {
const kJson = options.keycloakJson(options);
const keycloakUrl = getKeycloakUrl(kJson).replace('/auth', '');
publicKey = await KeyCloakCerts(keycloakUrl,
const keycloakUrl = new URL(getKeycloakUrl(kJson));
keycloakUrl.pathname = keycloakUrl.pathname.replace('/auth', '');
publicKey = await KeyCloakCerts(getUrl(keycloakUrl.toString()),
kJson.realm).fetch(kid);
await options.cache.put('publicKey', kid, publicKey);
}
Expand Down

0 comments on commit e4e6d6d

Please sign in to comment.