From e9098372afc5a816986c38a98baa7d44fe9ce78e Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Fri, 18 Oct 2024 17:20:16 +0400 Subject: [PATCH] UBERF-8500: Improve OIDC init logging (#6981) Signed-off-by: Alexey Zinoviev --- pods/authProviders/src/openid.ts | 34 ++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/pods/authProviders/src/openid.ts b/pods/authProviders/src/openid.ts index 297c1a5b0c..4029f2838a 100644 --- a/pods/authProviders/src/openid.ts +++ b/pods/authProviders/src/openid.ts @@ -38,21 +38,29 @@ export function registerOpenid ( const redirectURL = '/auth/openid/callback' if (openidClientId === undefined || openidClientSecret === undefined || issuer === undefined) return - void Issuer.discover(issuer).then((issuerObj) => { - const client = new issuerObj.Client({ - client_id: openidClientId, - client_secret: openidClientSecret, - redirect_uris: [concatLink(accountsUrl, redirectURL)], - response_types: ['code'] - }) + Issuer.discover(issuer) + .then((issuerObj) => { + measureCtx.info('Discovered issuer', { issuer: issuerObj }) - passport.use( - 'oidc', - new Strategy({ client, passReqToCallback: true }, (req: any, tokenSet: any, userinfo: any, done: any) => { - return done(null, userinfo) + const client = new issuerObj.Client({ + client_id: openidClientId, + client_secret: openidClientSecret, + redirect_uris: [concatLink(accountsUrl, redirectURL)], + response_types: ['code'] }) - ) - }) + measureCtx.info('Created OIDC client') + + passport.use( + 'oidc', + new Strategy({ client, passReqToCallback: true }, (req: any, tokenSet: any, userinfo: any, done: any) => { + return done(null, userinfo) + }) + ) + measureCtx.info('Registered OIDC strategy') + }) + .catch((err) => { + measureCtx.error('Failed to create OIDC client for IdP with the provided configuration', { err }) + }) router.get('/auth/openid', async (ctx, next) => { measureCtx.info('try auth via', { provider: 'openid' })