Frontend: - Add @azure/msal-browser and @azure/msal-react packages - Create authConfig.ts with MSAL configuration for PKCE flow - Create authService.ts for token acquisition and user info - Wrap App with MsalProvider in index.tsx - Replace dummy login with real MSAL loginPopup() in Login.tsx - Update App.tsx to use useIsAuthenticated/useMsal hooks - Update Profile.tsx to display real user data from claims - Update geminiService.ts to include access_token in WebSocket messages - Update WIPReviewer.tsx to pass msalInstance for auth Backend: - Add python-jose and httpx dependencies for JWT verification - Create auth_service.py with Azure AD JWKS fetching and token verification - Create auth.py FastAPI dependency for protected REST endpoints - Update main.py to verify tokens on WebSocket and protect /info endpoint - Add AZURE_TENANT_ID, AZURE_CLIENT_ID, DISABLE_AUTH to config 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
1.9 KiB
TypeScript
52 lines
1.9 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 .default for single-tenant apps to get all configured API permissions
|
|
export const loginRequest: PopupRequest = {
|
|
scopes: [`api://${import.meta.env.VITE_AZURE_CLIENT_ID || ''}/.default`],
|
|
};
|
|
|
|
// Scopes for API calls (same as login for this app)
|
|
export const apiTokenRequest = {
|
|
scopes: [`api://${import.meta.env.VITE_AZURE_CLIENT_ID || ''}/.default`],
|
|
};
|