forked from exlinc/keycloak-passport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.js
29 lines (27 loc) · 955 Bytes
/
configuration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
module.exports = class KeycloakEnvConfig {
constructor(inputOptions) {
const defaultOptions = {
host: process.env.KEYCLOAK_HOST,
realm: process.env.KEYCLOAK_REALM,
clientID: process.env.KEYCLOAK_CLIENT_ID,
clientSecret: process.env.KEYCLOAK_CLIENT_SECRET,
callbackURL: process.env.SITE_URL,
scope: "openid",
additionalClaims: [],
skipPrefix: true,
};
const options = Object.assign(defaultOptions, inputOptions);
this.update(options);
}
update(options) {
Object.keys(options).forEach((key) => {
this[key] = options[key];
});
this.prefix = (this.skipPrefix ? "" : "/auth")
this.mainURL = `${this.host}${this.prefix}/realms/${this.realm}/protocol/openid-connect`
this.authorizationURL = `${this.mainURL}/auth`;
this.tokenURL = `${this.mainURL}/token`;
this.userInfoURL = `${this.mainURL}/userinfo`;
this.logOutURL = `${this.mainURL}/logout`;
}
};