exlinc / keycloak-passport

Production-ready multi-realm implementation of a Keycloak Passport Strategy
https://exlskills.com/learn
Apache License 2.0
96 stars 22 forks source link

authorizationURL required? #14

Open ajmas opened 3 years ago

ajmas commented 3 years ago

Looking at the example in the README, no indication of needing authorizationURL is provided, but I get (truncated):

 Error: authorizationURL is required
    at /Users/ajmas/Development/myproject/node_modules/@exlinc/keycloak-passport/index.js:16:13
    at Array.forEach (<anonymous>)
    at new Strategy (/Users/ajmas/Development/myproject/node_modules/@exlinc/keycloak-passport/index.js:14:5)
    at Object.initPassport (/Users/ajmas/Development/myproject/src/middleware/passport.ts:234:18)

Looking at the source of this package, I see the following:

  [
    'host',
    'realm',
    'clientID',
    'clientSecret',
    'callbackURL',
    'authorizationURL',
    'tokenURL',
    'userInfoURL'
  ].forEach((k) => {
    if (!options[k]) {
      throw new Error(`${k} is required`);
    }
  });

Which suggests it is required, but then I see configuration.js which resolves the missing URLs, but I am not sure how it is to be used to resolve this issue?

Navjot-Sharma commented 2 years ago

I know it's a bit late but for future reference for anyone else, it can be used like this

` import KeycloakEnvConfig from "@exlinc/keycloak-passport/configuration.js";

const config = new KeycloakEnvConfig({ host: '', realm: '', clientID: '', clientSecret: '', callbackURL: '', });

console.log('keycloak config', config);

// Register the strategy with passport

passport.use( "keycloak", new KeycloakStrategy(config, (accessToken, refreshToken, profile, done) => {});`