feat(sso): enhance OIDC registration mapping for Azure and other providers

- Updated the mapping logic in `register-oidc-dialog` to differentiate between Azure and other identity providers.
- Simplified the mapping structure for user attributes based on the issuer, improving flexibility in handling various OIDC providers.
This commit is contained in:
Mauricio Siu
2026-02-01 00:35:42 -06:00
parent 00ce8cad1b
commit 11082f25d7
2 changed files with 21 additions and 12 deletions

View File

@@ -101,6 +101,22 @@ export function RegisterOidcDialog({ children }: RegisterOidcDialogProps) {
const scopes = data.scopes.filter(Boolean).length
? data.scopes.filter(Boolean)
: DEFAULT_SCOPES;
const isAzure = data.issuer.includes("login.microsoftonline.com");
const mapping = isAzure
? {
id: "sub",
email: "preferred_username",
emailVerified: "email_verified",
name: "name",
}
: {
id: "sub",
email: "email",
emailVerified: "email_verified",
name: "preferred_username",
image: "picture",
};
await mutateAsync({
providerId: data.providerId,
issuer: data.issuer,
@@ -110,14 +126,7 @@ export function RegisterOidcDialog({ children }: RegisterOidcDialogProps) {
clientSecret: data.clientSecret,
scopes,
pkce: true,
// Keycloak (and many IdPs) send preferred_username; better-auth expects name
mapping: {
id: "sub",
email: "email",
emailVerified: "email_verified",
name: "preferred_username",
image: "picture",
},
mapping,
},
});

View File

@@ -109,12 +109,12 @@ export const SSOSettings = () => {
Add OIDC provider
</Button>
</RegisterOidcDialog>
<RegisterSamlDialog>
{/* <RegisterSamlDialog>
<Button variant="secondary" size="sm">
<LogIn className="mr-2 size-4" />
Add SAML provider
</Button>
</RegisterSamlDialog>
</RegisterSamlDialog> */}
</div>
)}
@@ -234,12 +234,12 @@ export const SSOSettings = () => {
Add OIDC provider
</Button>
</RegisterOidcDialog>
<RegisterSamlDialog>
{/* <RegisterSamlDialog>
<Button variant="outline">
<LogIn className="mr-2 size-4" />
Add SAML provider
</Button>
</RegisterSamlDialog>
</RegisterSamlDialog> */}
</div>
</div>
)}