- Change frontend scopes from api://{client_id}/.default to
openid, profile, email for simpler authentication
- Update backend token validation to expect ID token format:
- Audience: client_id (not api://{client_id})
- Issuer: v2.0 endpoint
This avoids requiring Application ID URI setup in Azure AD.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
1.8 KiB
TypeScript
52 lines
1.8 KiB
TypeScript
/**
|
|
* MSAL (Microsoft Authentication Library) configuration for Azure AD SSO.
|
|
* Uses PKCE flow by default for SPA security.
|
|
*/
|
|
import { Configuration, LogLevel, PopupRequest } from '@azure/msal-browser';
|
|
|
|
// MSAL configuration - uses PKCE by default for SPAs
|
|
export const msalConfig: Configuration = {
|
|
auth: {
|
|
clientId: import.meta.env.VITE_AZURE_CLIENT_ID || '',
|
|
authority: `https://login.microsoftonline.com/${import.meta.env.VITE_AZURE_TENANT_ID || 'common'}`,
|
|
redirectUri: import.meta.env.VITE_AZURE_REDIRECT_URI || window.location.origin,
|
|
postLogoutRedirectUri: window.location.origin,
|
|
},
|
|
cache: {
|
|
cacheLocation: 'localStorage', // Persists auth state across browser tabs/refresh
|
|
storeAuthStateInCookie: false, // Not needed for modern browsers
|
|
},
|
|
system: {
|
|
loggerOptions: {
|
|
loggerCallback: (level, message, containsPii) => {
|
|
if (containsPii) return;
|
|
switch (level) {
|
|
case LogLevel.Error:
|
|
console.error(message);
|
|
break;
|
|
case LogLevel.Warning:
|
|
console.warn(message);
|
|
break;
|
|
case LogLevel.Info:
|
|
console.info(message);
|
|
break;
|
|
case LogLevel.Verbose:
|
|
console.debug(message);
|
|
break;
|
|
}
|
|
},
|
|
logLevel: LogLevel.Warning,
|
|
},
|
|
},
|
|
};
|
|
|
|
// Scopes for the access token
|
|
// Using basic OpenID scopes for authentication
|
|
export const loginRequest: PopupRequest = {
|
|
scopes: ['openid', 'profile', 'email'],
|
|
};
|
|
|
|
// Scopes for API calls (same as login for this app)
|
|
export const apiTokenRequest = {
|
|
scopes: ['openid', 'profile', 'email'],
|
|
};
|