Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(sso-router, saml-router, oidc-config-service): ensure callback is called with loginResult after successful authentication

Victor Hugo dos Santosfecaea6ad954
diff --git a/backend/src/ee/routes/v1/saml-router.ts b/backend/src/ee/routes/v1/saml-router.ts
index 1c01d14ece..00e26e3721 100644
--- a/backend/src/ee/routes/v1/saml-router.ts
+++ b/backend/src/ee/routes/v1/saml-router.ts
@@ -190,6 +190,8 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
metadata: userMetadata
});
+ cb(null, loginResult);
+
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
"infisical.user.email": email.toLowerCase(),
@@ -209,8 +211,6 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
result: AuthAttemptAuthResult.SUCCESS,
orgId: loginResult.orgId
});
-
- cb(null, loginResult);
} catch (error) {
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
diff --git a/backend/src/ee/services/oidc/oidc-config-service.ts b/backend/src/ee/services/oidc/oidc-config-service.ts
index 24b4d08c1d..99ecff94f0 100644
--- a/backend/src/ee/services/oidc/oidc-config-service.ts
+++ b/backend/src/ee/services/oidc/oidc-config-service.ts
@@ -801,6 +801,8 @@ export const oidcConfigServiceFactory = ({
manageGroupMemberships: oidcCfg.manageGroupMemberships
})
.then((loginResult) => {
+ cb(null, loginResult);
+
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
"infisical.user.email": claims?.email?.toLowerCase(),
@@ -820,8 +822,6 @@ export const oidcConfigServiceFactory = ({
result: AuthAttemptAuthResult.SUCCESS,
orgId: org.id
});
-
- cb(null, loginResult);
})
.catch((error: unknown) => {
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.ts
index ac74d16561..68d574ad2a 100644
--- a/backend/src/server/routes/v1/sso-router.ts
+++ b/backend/src/server/routes/v1/sso-router.ts
@@ -100,6 +100,8 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
);
}
+ cb(null, loginResult);
+
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
"infisical.user.email": email,
@@ -119,8 +121,6 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
result: AuthAttemptAuthResult.SUCCESS,
orgId: loginResult.orgId
});
-
- cb(null, loginResult);
} catch (error) {
logger.error(error);
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
@@ -202,6 +202,8 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
);
}
+ done(null, { ...loginResult, externalProviderAccessToken: accessToken });
+
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
"infisical.user.email": email,
@@ -221,8 +223,6 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
result: AuthAttemptAuthResult.SUCCESS,
orgId: loginResult.orgId
});
-
- done(null, { ...loginResult, externalProviderAccessToken: accessToken });
} catch (err) {
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
@@ -296,6 +296,8 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
);
}
+ cb(null, loginResult);
+
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {
"infisical.user.email": email,
@@ -315,8 +317,6 @@ export const registerOauthMiddlewares = (server: FastifyZodProvider) => {
result: AuthAttemptAuthResult.SUCCESS,
orgId: loginResult.orgId
});
-
- return cb(null, loginResult);
} catch (error) {
if (appCfg.OTEL_TELEMETRY_COLLECTION_ENABLED) {
authAttemptCounter.add(1, {