|
@@ -570,49 +570,56 @@ class PassportService implements S2sMessageHandlable {
|
|
|
|
|
|
|
|
// Prevent request timeout error on app init
|
|
// Prevent request timeout error on app init
|
|
|
const oidcIssuer = await this.getOIDCIssuerInstance(issuerHost);
|
|
const oidcIssuer = await this.getOIDCIssuerInstance(issuerHost);
|
|
|
|
|
+
|
|
|
if (oidcIssuer != null) {
|
|
if (oidcIssuer != null) {
|
|
|
|
|
+ const oidcIssuerMetadata = oidcIssuer.metadata;
|
|
|
|
|
+
|
|
|
logger.debug('Discovered issuer %s %O', oidcIssuer.issuer, oidcIssuer.metadata);
|
|
logger.debug('Discovered issuer %s %O', oidcIssuer.issuer, oidcIssuer.metadata);
|
|
|
|
|
|
|
|
const authorizationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:authorizationEndpoint');
|
|
const authorizationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:authorizationEndpoint');
|
|
|
if (authorizationEndpoint) {
|
|
if (authorizationEndpoint) {
|
|
|
- oidcIssuer.metadata.authorization_endpoint = authorizationEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.authorization_endpoint = authorizationEndpoint;
|
|
|
}
|
|
}
|
|
|
const tokenEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:tokenEndpoint');
|
|
const tokenEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:tokenEndpoint');
|
|
|
if (tokenEndpoint) {
|
|
if (tokenEndpoint) {
|
|
|
- oidcIssuer.metadata.token_endpoint = tokenEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.token_endpoint = tokenEndpoint;
|
|
|
}
|
|
}
|
|
|
const revocationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:revocationEndpoint');
|
|
const revocationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:revocationEndpoint');
|
|
|
if (revocationEndpoint) {
|
|
if (revocationEndpoint) {
|
|
|
- oidcIssuer.metadata.revocation_endpoint = revocationEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.revocation_endpoint = revocationEndpoint;
|
|
|
}
|
|
}
|
|
|
const introspectionEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:introspectionEndpoint');
|
|
const introspectionEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:introspectionEndpoint');
|
|
|
if (introspectionEndpoint) {
|
|
if (introspectionEndpoint) {
|
|
|
- oidcIssuer.metadata.introspection_endpoint = introspectionEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.introspection_endpoint = introspectionEndpoint;
|
|
|
}
|
|
}
|
|
|
const userInfoEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:userInfoEndpoint');
|
|
const userInfoEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:userInfoEndpoint');
|
|
|
if (userInfoEndpoint) {
|
|
if (userInfoEndpoint) {
|
|
|
- oidcIssuer.metadata.userinfo_endpoint = userInfoEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.userinfo_endpoint = userInfoEndpoint;
|
|
|
}
|
|
}
|
|
|
const endSessionEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:endSessionEndpoint');
|
|
const endSessionEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:endSessionEndpoint');
|
|
|
if (endSessionEndpoint) {
|
|
if (endSessionEndpoint) {
|
|
|
- oidcIssuer.metadata.end_session_endpoint = endSessionEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.end_session_endpoint = endSessionEndpoint;
|
|
|
}
|
|
}
|
|
|
const registrationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:registrationEndpoint');
|
|
const registrationEndpoint = configManager.getConfig('crowi', 'security:passport-oidc:registrationEndpoint');
|
|
|
if (registrationEndpoint) {
|
|
if (registrationEndpoint) {
|
|
|
- oidcIssuer.metadata.registration_endpoint = registrationEndpoint;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.registration_endpoint = registrationEndpoint;
|
|
|
}
|
|
}
|
|
|
const jwksUri = configManager.getConfig('crowi', 'security:passport-oidc:jwksUri');
|
|
const jwksUri = configManager.getConfig('crowi', 'security:passport-oidc:jwksUri');
|
|
|
if (jwksUri) {
|
|
if (jwksUri) {
|
|
|
- oidcIssuer.metadata.jwks_uri = jwksUri;
|
|
|
|
|
|
|
+ oidcIssuerMetadata.jwks_uri = jwksUri;
|
|
|
}
|
|
}
|
|
|
- logger.debug('Configured issuer %s %O', oidcIssuer.issuer, oidcIssuer.metadata);
|
|
|
|
|
|
|
|
|
|
- const client = new oidcIssuer.Client({
|
|
|
|
|
|
|
+ const newOidcIssuer = new OIDCIssuer(oidcIssuerMetadata);
|
|
|
|
|
+
|
|
|
|
|
+ const client = new newOidcIssuer.Client({
|
|
|
client_id: clientId,
|
|
client_id: clientId,
|
|
|
client_secret: clientSecret,
|
|
client_secret: clientSecret,
|
|
|
redirect_uris: [redirectUri],
|
|
redirect_uris: [redirectUri],
|
|
|
response_types: ['code'],
|
|
response_types: ['code'],
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ logger.debug('Configured issuer %s %O', newOidcIssuer.issuer, newOidcIssuer.metadata);
|
|
|
|
|
+
|
|
|
// prevent error AssertionError [ERR_ASSERTION]: id_token issued in the future
|
|
// prevent error AssertionError [ERR_ASSERTION]: id_token issued in the future
|
|
|
// Doc: https://github.com/panva/node-openid-client/tree/v2.x#allow-for-system-clock-skew
|
|
// Doc: https://github.com/panva/node-openid-client/tree/v2.x#allow-for-system-clock-skew
|
|
|
const OIDC_CLIENT_CLOCK_TOLERANCE = await this.crowi.configManager.getConfig('crowi', 'security:passport-oidc:oidcClientClockTolerance');
|
|
const OIDC_CLIENT_CLOCK_TOLERANCE = await this.crowi.configManager.getConfig('crowi', 'security:passport-oidc:oidcClientClockTolerance');
|