More fixes in SSO

This commit is contained in:
Arunavo Ray
2025-07-26 20:33:26 +05:30
parent 1f6add5fff
commit 0920314679
8 changed files with 1866 additions and 14 deletions

View File

@@ -77,7 +77,7 @@ export async function POST(context: APIContext) {
jwksEndpoint,
discoveryEndpoint,
userInfoEndpoint,
scopes = ["openid", "email", "profile"],
scopes,
pkce = true,
mapping = {
id: "sub",
@@ -88,6 +88,23 @@ export async function POST(context: APIContext) {
}
} = body;
// Handle provider-specific scope defaults
let finalScopes = scopes;
if (!finalScopes) {
// Check if this is a Google provider
const isGoogle = issuer.includes('google.com') ||
issuer.includes('googleapis.com') ||
domain.includes('google.com');
if (isGoogle) {
// Google doesn't support offline_access scope
finalScopes = ["openid", "email", "profile"];
} else {
// Default scopes for other providers
finalScopes = ["openid", "email", "profile", "offline_access"];
}
}
registrationBody.oidcConfig = {
clientId,
clientSecret,
@@ -96,7 +113,7 @@ export async function POST(context: APIContext) {
jwksEndpoint,
discoveryEndpoint,
userInfoEndpoint,
scopes,
scopes: finalScopes,
pkce,
};
registrationBody.mapping = mapping;