microsoft/power-platform-skills / plugins/power-pages/skills/setup-auth
setup-auth
VerifiedUse when the user asks to "set up authentication", "add login", "add logout", "add sign in", "enable auth", "add role-based access", "add authorization", "protect routes", "configure identity provider", "configure Entra ID", "configure Entra External ID", "configure OpenID Connect", "add OIDC", "set up SAML", "set up WS-Federation", "set up local login", "add Facebook login", "add Google sign in", "add Microsoft Account", or otherwise wants to set up authentication (login/logout) and role-based authorization for their Power Pages SPA site using any supported identity provider. Also sets up the IdP app registration for OIDC providers (Okta, Auth0, Entra External ID, and other OIDC) -- reads the provider's docs first, then either guides the user through the provider's console or, when the provider supports it, configures it for the user -- and wires the client ID, authority, and claims mapping into Power Pages.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 225.7 KB |
| assets/auth-report.html | other | 24.1 KB |
| references/authentication-reference.md | markdown | 168.1 KB |
| references/authorization-reference.md | markdown | 8.5 KB |
| references/idp-provisioning-reference.md | markdown | 6.9 KB |
| scripts/validate-auth.js | script | 6.5 KB |
scripts/validate-auth.js
View on GitHub#!/usr/bin/env node
// Validates that authentication and authorization code was created for a
// Power Pages SPA site. Runs as a PostToolUse:Skill hook (configured in
// hooks/hooks.json) after the `Skill` tool fires for /power-pages:setup-auth.
//
// Because PostToolUse fires when the Skill tool LOADS (instructions are read
// into context) rather than when the skill has FINISHED its work, this
// validator gates on a finishing marker: the auth setup report HTML written
// by the skill's final Phase 8.3.5. Until that report exists, the skill is
// considered in-progress and validation silent-approves. This follows the
// marker-file recommendation in plugins/power-pages/PLUGIN_DEVELOPMENT_GUIDE.md.
const fs = require('fs');
const path = require('path');
const { approve, block, runValidation, findProjectRoot } = require('../../../scripts/lib/validation-helpers');
runValidation((cwd) => {
const projectRoot = findProjectRoot(cwd);
if (!projectRoot) return approve(); // Not a Power Pages project, skip
// Check if any auth files exist — if none, this wasn't an auth session
const authServiceExists = findAuthService(projectRoot);
const typeDeclarationsExist = findTypeDeclarations(projectRoot);
if (!authServiceExists && !typeDeclarationsExist) return approve();
// Marker gate: silent-approve until the skill writes its finishing report.
// Without this gate, re-running setup-auth on a project that has stale auth
// files from a previous attempt would block the new run before it could
// overwrite them.
if (!hasFinishingMarker(projectRoot)) return approve();
const errors = [];
if (!authServiceExists) {
errors.push('Missing auth service (src/services/authService.ts or equivalent)');
}
if (!typeDeclarationsExist) {
errors.push('Missing Power Pages type declarations (src/types/powerPages.d.ts)');
}
// Validate auth service content if it exists
if (authServiceExists) {
const content = fs.readFileSync(authServiceExists, 'utf8');
if (!content.includes('login')) {
errors.push('Auth service missing login function');
}
if (!content.includes('logout')) {
errors.push('Auth service missing logout function');
}
if (!content.includes('getCurrentUser')) {
errors.push('Auth service missing getCurrentUser function');
}
if (!content.includes('/_layout/tokenhtml') && !content.includes('fetchAntiForgeryToken')) {
errors.push('Auth service missing anti-forgery token handling');
}
// Verify provider configuration exists. The canonical pattern in
// authentication-reference.md is the AUTH_PROVIDERS array (even single-
// provider sites use a one-element array — see SKILL.md and the
// "Multiple Providers — Canonical AUTH_PROVIDERS Array Pattern" section
// of authentication-reference.md). AuthProviderConfig is the interface
// name and is also a valid marker (auth service must declare the type).
if (!content.includes('AUTH_PROVIDERS') && !content.includes('AuthProviderConfig')) {
errors.push('Auth service missing provider configuration — expected the AUTH_PROVIDERS array or AuthProviderConfig type. The canonical pattern is `export const AUTH_PROVIDERS: AuthProviderConfig[] = [...]` even when only one provider is configured.');
}
}
// Check for authorization utilities — only if auth service references role-checking
// (skip for "Login & Logout only" scope where authorization utils are not created)
const authzUtils = findAuthorizationUtils(projectRoot);
if (!authzUtils && authServiceExists) {
const authContent = fs.readFileSync(authServiceExists, 'utf8');
// Only flag missing authz utils if the auth service imports or references them
if (authContent.includes('authorization') || authContent.includes('hasRole') || authContent.includes('getUserRoles')) {
errors.push('Missing authorization utilities (src/utils/authorization.ts or equivalent)');
}
}
// Check for auth UI component
const authComponent = findAuthComponent(projectRoot);
if (!authComponent) {
errors.push('Missing auth UI component (AuthButton or equivalent)');
}
if (errors.length > 0) {
block('Authentication setup validation failed:\n- ' + errors.join('\n- '));
}
approve();
});
function hasFinishingMarker(projectRoot) {
// The skill writes `docs/auth-setup-report.html` at the end of Phase 8.3.5.
// If the user already had a previous report there, the renderer date-suffixes
// the new one (auth-setup-report-2026-05-27.html). Treat any matching file
// in docs/ as evidence that the skill has completed at least one run.
const docsDir = path.join(projectRoot, 'docs');
if (!fs.existsSync(docsDir)) return false;
try {
return fs.readdirSync(docsDir).some((name) =>
/^auth-setup-report.*\.html$/.test(name)
);
} catch {
return false;
}
}
function findAuthService(projectRoot) {
const candidates = [
path.join(projectRoot, 'src', 'services', 'authService.ts'),
path.join(projectRoot, 'src', 'services', 'authService.js'),
path.join(projectRoot, 'src', 'services', 'auth.service.ts'),
path.join(projectRoot, 'src', 'services', 'auth.service.js'),
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) return candidate;
}
return null;
}
function findTypeDeclarations(projectRoot) {
const candidates = [
path.join(projectRoot, 'src', 'types', 'powerPages.d.ts'),
path.join(projectRoot, 'src', 'types', 'powerPages.ts'),
path.join(projectRoot, 'src', 'types', 'power-pages.d.ts'),
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) return true;
}
return false;
}
function findAuthorizationUtils(projectRoot) {
const candidates = [
path.join(projectRoot, 'src', 'utils', 'authorization.ts'),
path.join(projectRoot, 'src', 'utils', 'authorization.js'),
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) return candidate;
}
return null;
}
function findAuthComponent(projectRoot) {
const searchDirs = [
path.join(projectRoot, 'src', 'components'),
path.join(projectRoot, 'src', 'app', 'components'),
];
for (const dir of searchDirs) {
if (!fs.existsSync(dir)) continue;
try {
for (const file of fs.readdirSync(dir, { recursive: true })) {
const name = typeof file === 'string' ? file : file.toString();
if (name.toLowerCase().includes('auth') && (name.endsWith('.tsx') || name.endsWith('.vue') || name.endsWith('.ts') || name.endsWith('.astro'))) {
return path.join(dir, name);
}
}
} catch {}
}
return null;
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization. | Stars: 469k | Updated | Claude CodeCodex | Verified | Install |
| academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file). | Stars: 197k | Updated | Claude CodeCodex | Unverified | Install |
| doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |