UBERF-8500: Improve OIDC init logging (#6981)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2024-10-18 17:20:16 +04:00 committed by GitHub
parent f4393df8f3
commit e9098372af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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' })