Skip to content

Commit

Permalink
Add providerName to trace context and requested
Browse files Browse the repository at this point in the history
  • Loading branch information
niwsa committed Jan 26, 2025
1 parent 2cb32fa commit 48af9d0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions npm/src/controller/oauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export class OAuthController implements IOAuthController {
// Connection retrieved: Handover to IdP starts here
let ssoUrl;
let post = false;
let providerName;

// Init sessionId
const sessionId = crypto.randomBytes(16).toString('hex');
Expand All @@ -365,7 +366,8 @@ export class OAuthController implements IOAuthController {
let samlReq, internalError;
if (connectionIsSAML) {
try {
const { sso } = (connection as SAMLSSORecord).idpMetadata;
const { sso, provider } = (connection as SAMLSSORecord).idpMetadata;
providerName = provider;

if ('redirectUrl' in sso) {
// HTTP Redirect binding
Expand Down Expand Up @@ -394,6 +396,7 @@ export class OAuthController implements IOAuthController {
requestedOIDCFlow,
isOIDCFederated,
redirectUri: redirect_uri,
providerName: provider,
},
});
return {
Expand Down Expand Up @@ -454,7 +457,9 @@ export class OAuthController implements IOAuthController {
let oidcCodeVerifier: string | undefined;
let oidcNonce: string | undefined;
if (connectionIsOIDC) {
const { discoveryUrl, metadata, clientId, clientSecret } = (connection as OIDCSSORecord).oidcProvider;
const { discoveryUrl, metadata, clientId, clientSecret, provider } = (connection as OIDCSSORecord)
.oidcProvider;
providerName = provider;
const { ssoTraces } = this;
try {
if (!this.opts.oidcPath) {
Expand All @@ -479,6 +484,7 @@ export class OAuthController implements IOAuthController {
requestedOIDCFlow,
isOIDCFederated,
redirectUri: redirect_uri,
providerName: provider,
},
},
});
Expand Down Expand Up @@ -520,6 +526,7 @@ export class OAuthController implements IOAuthController {
requestedOIDCFlow,
isOIDCFederated,
redirectUri: redirect_uri,
providerName,
},
});

Expand All @@ -537,7 +544,7 @@ export class OAuthController implements IOAuthController {
}
// Session persistence happens here
try {
const requested = { client_id, state, redirect_uri, protocol, login_type } as Record<
const requested = { client_id, state, redirect_uri, protocol, login_type, providerName } as Record<
string,
string | boolean | string[]
>;
Expand Down Expand Up @@ -639,6 +646,7 @@ export class OAuthController implements IOAuthController {
isOIDCFederated,
redirectUri: redirect_uri,
samlRequest: samlReq?.request || '',
providerName,
},
});
return {
Expand Down Expand Up @@ -1078,7 +1086,12 @@ export class OAuthController implements IOAuthController {
const code = crypto.randomBytes(20).toString('hex');

const requested = isIdPFlow
? { isIdPFlow: true, tenant: connection.tenant, product: connection.product }
? {
isIdPFlow: true,
tenant: connection.tenant,
product: connection.product,
providerName: (connection as SAMLSSORecord).idpMetadata.provider,
}
: session
? session.requested
: null;
Expand Down

0 comments on commit 48af9d0

Please sign in to comment.