Skip to content

LeoYeAI/agent-master-skills / skills/azure-auth

azure-auth

Verified

Microsoft 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.

templates/msal-config.ts

View on GitHub
/**
 * MSAL Configuration for Microsoft Entra ID (Azure AD)
 *
 * Replace environment variables with your Azure app registration values:
 * - VITE_AZURE_CLIENT_ID: Application (client) ID from Azure Portal
 * - VITE_AZURE_TENANT_ID: Directory (tenant) ID from Azure Portal
 */

import { Configuration, LogLevel } from "@azure/msal-browser";

export const msalConfig: Configuration = {
  auth: {
    // Application (client) ID from Azure Portal
    clientId: import.meta.env.VITE_AZURE_CLIENT_ID,

    // Authority URL - single tenant
    // For multi-tenant, use: "https://login.microsoftonline.com/common"
    // For work/school only: "https://login.microsoftonline.com/organizations"
    authority: `https://login.microsoftonline.com/${import.meta.env.VITE_AZURE_TENANT_ID}`,

    // Redirect URI - must match Azure Portal configuration exactly
    redirectUri: window.location.origin,

    // Where to redirect after logout
    postLogoutRedirectUri: window.location.origin,

    // Navigate back to the original page after login
    navigateToLoginRequestUrl: true,
  },

  cache: {
    // Where to store auth state
    // "localStorage" persists across tabs, "sessionStorage" is per-tab
    cacheLocation: "localStorage",

    // CRITICAL: Required for Safari and Edge compatibility
    // These browsers have stricter cookie policies that can break auth state
    storeAuthStateInCookie: true,
  },

  system: {
    loggerOptions: {
      logLevel: LogLevel.Warning,
      loggerCallback: (level, message, containsPii) => {
        if (containsPii) return; // Never log PII

        switch (level) {
          case LogLevel.Error:
            console.error("[MSAL]", message);
            break;
          case LogLevel.Warning:
            console.warn("[MSAL]", message);
            break;
          case LogLevel.Info:
            console.info("[MSAL]", message);
            break;
          case LogLevel.Verbose:
            console.debug("[MSAL]", message);
            break;
        }
      },
    },
    // Prevent popup/iframe timeouts on slow networks
    windowHashTimeout: 60000,
    iframeHashTimeout: 6000,
    loadFrameTimeout: 0,
  },
};

/**
 * Scopes for initial login
 * - openid, profile, email are standard OIDC scopes
 * - User.Read allows reading the signed-in user's profile from Microsoft Graph
 */
export const loginRequest = {
  scopes: ["openid", "profile", "email", "User.Read"],
};

/**
 * Scopes for calling your own API
 * Replace with your API's scope URI from Azure Portal:
 * App Registration > Expose an API > Add a scope
 *
 * Format: api://{client_id}/{scope_name}
 */
export const apiRequest = {
  scopes: [`api://${import.meta.env.VITE_AZURE_CLIENT_ID}/access_as_user`],
};

/**
 * Scopes for Microsoft Graph API calls
 * Add additional Graph scopes as needed:
 * - Mail.Read, Mail.Send for email
 * - Calendars.Read, Calendars.ReadWrite for calendar
 * - Files.Read, Files.ReadWrite for OneDrive
 */
export const graphRequest = {
  scopes: ["User.Read"],
};
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall