From 65ee7169f8af94c7096e68142416ad0468dad3ca Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Wed, 15 Feb 2023 14:53:38 +0000 Subject: [PATCH] Add error logging for user save failure in sso authentication --- .../src/middleware/passport/third-party-common.ts | 2 +- packages/worker/src/api/controllers/global/auth.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/backend-core/src/middleware/passport/third-party-common.ts b/packages/backend-core/src/middleware/passport/third-party-common.ts index 451cdf6cc6..9d7b93f370 100644 --- a/packages/backend-core/src/middleware/passport/third-party-common.ts +++ b/packages/backend-core/src/middleware/passport/third-party-common.ts @@ -94,7 +94,7 @@ export async function authenticateThirdParty( try { await saveUserFn(dbUser, { hashPassword: false, requirePassword: false }) } catch (err: any) { - return authError(done, err) + return authError(done, "Error saving user", err) } // now that we're sure user exists, load them from the db diff --git a/packages/worker/src/api/controllers/global/auth.ts b/packages/worker/src/api/controllers/global/auth.ts index e6d3c329d7..738b67c553 100644 --- a/packages/worker/src/api/controllers/global/auth.ts +++ b/packages/worker/src/api/controllers/global/auth.ts @@ -27,13 +27,16 @@ export async function oidcCallbackUrl(config?: { callbackURL?: string }) { return ssoCallbackUrl(tenancy.getGlobalDB(), config, ConfigType.OIDC) } -async function authInternal(ctx: any, user: any, err = null, info = null) { +async function authInternal(ctx: any, user: any, err: any = null, info = null) { if (err) { - console.error("Authentication error", err) + console.error("Authentication error") + console.error(err) + console.trace(err) return ctx.throw(403, info ? info : "Unauthorized") } if (!user) { + console.error("Authentication error - no user provided") return ctx.throw(403, info ? info : "Unauthorized") }