LeoYeAI/agent-master-skills / skills/azure-auth
azure-auth
VerifiedMicrosoft Entra ID (Azure AD) authentication for React SPAs with MSAL.js and Cloudflare Workers JWT validation using jose library. Full-stack pattern with Authorization Code Flow + PKCE. Prevents 8 documented errors. Use when: implementing Microsoft SSO, troubleshooting AADSTS50058 loops, AADSTS700084 refresh token errors, React Router redirects, setActiveAccount re-render issues, or validating Entra ID tokens in Workers.
| File | Kind | Size |
|---|---|---|
| .claude-plugin/plugin.json | config | 688 B |
| README.md | markdown | 2.5 KB |
| SKILL.md | skill md | 19.7 KB |
| _meta.json | config | 284 B |
| references/aadsts-error-codes.md | markdown | 7.7 KB |
| rules/azure-auth.md | markdown | 3.4 KB |
| templates/msal-config.ts | script | 2.9 KB |
| templates/msal-provider.tsx | other | 4.5 KB |
| templates/protected-route.tsx | other | 7.1 KB |
| templates/use-api-token.ts | script | 6.0 KB |
| templates/workers-jwt-validation.ts | script | 8.3 KB |
rules/azure-auth.md
View on GitHub# Azure Auth Correction Rules
Rules for Microsoft Entra ID (Azure AD) authentication with MSAL React and Cloudflare Workers.
## MSAL Configuration
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| `cacheLocation: "sessionStorage"` without cookie flag | Add `storeAuthStateInCookie: true` for Safari/Edge |
| Creating MSAL instance inside component | Create outside component tree to prevent re-instantiation |
| Using implicit flow | Authorization Code Flow with PKCE (MSAL v3 default) |
| `authority: "https://login.microsoftonline.com/common"` for enterprise | Use tenant-specific authority for single-tenant apps |
## Token Acquisition
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| `acquireTokenSilent` without checking accounts | Check `getAllAccounts().length > 0` first |
| Catching generic error on acquireTokenSilent | Catch `InteractionRequiredAuthError` specifically |
| Ignoring AADSTS700084 | Handle as "refresh token expired, need interactive login" |
| Calling interactive method without checking inProgress | Check `inProgress !== InteractionStatus.None` first |
## Cloudflare Workers JWT Validation
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| Using MSAL.js in Workers | Use jose library (MSAL doesn't work in Workers) |
| Fetching JWKS from `.well-known/jwks.json` | Fetch from `openid-configuration` first, use `jwks_uri` |
| Hardcoding JWKS public key | Fetch dynamically and cache (keys rotate) |
| Single issuer validation for multi-tenant | Validate issuer matches `tid` claim from token |
## React Router Integration
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| Using `MsalAuthenticationTemplate` on redirect URI page | Don't render auth components on redirect page |
| Ignoring hash fragment in React Router v6 | Implement custom `NavigationClient` |
| Calling `loginRedirect` in render | Use `useEffect` or event handler |
## Azure Portal Configuration
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| "Web" platform for SPA | "Single-page application" platform type |
| Implicit grant only | Enable "Access tokens" and "ID tokens" under Authentication |
| Skipping redirect URI for localhost | Add `http://localhost:5173` (or your dev port) |
## Common AADSTS Errors
| Error Code | Meaning | Fix |
|------------|---------|-----|
| AADSTS50058 | Silent sign-in, no user | Check for cached accounts before silent acquisition |
| AADSTS700084 | Refresh token expired (24hr SPA limit) | Trigger interactive login |
| AADSTS65001 | Consent not granted | Request admin consent or prompt user |
| AADSTS90102 | Redirect URI mismatch | Verify URI in Azure Portal matches exactly |
| AADSTS50011 | Reply URL doesn't match | Check trailing slashes, http vs https |
## Environment Variables
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| Hardcoding client ID | Use `import.meta.env.VITE_AZURE_CLIENT_ID` |
| Exposing tenant ID in git | Store in `.env` (gitignored) or CI/CD secrets |
| Using `process.env` in Vite | Use `import.meta.env` for Vite projects |
## Azure AD B2C (Sunset May 2025)
| If Claude suggests... | Use instead... |
|----------------------|----------------|
| Setting up new Azure AD B2C | Use Microsoft Entra External ID for consumer apps |
| B2C authority URL for new projects | Entra External ID authority format |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |