frontend-authentication
Use when the user asks to implement JWT login with refresh tokens in the browser, OAuth2/OIDC with PKCE, protected routes and route guards, token storage…
от j4flmao★ 47 звёзд на GitHub
Установить frontend-authentication в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
Frontend Authentication
Purpose
Implement secure authentication on the frontend: token acquisition, storage, route protection, session refresh, and logout — compatible with any auth provider. Tokens are stored securely. Routes are guarded by middleware or wrapper components. OAuth flows follow PKCE best practices.
Agent Protocol
Trigger
Exact phrases: "auth", "authentication", "login", "signup", "JWT", "OAuth", "route guard", "protected route", "token storage", "refresh token", "session", "access token", "logout", "SSO", "magic link", "MFA".
Input Context
- Framework (React, Vue, Angular, Svelte)
- Auth provider (Auth0, Clerk, Supabase, Firebase, Cognito, custom)
- OAuth or credentials-based flow
- Session strategy (JWT + refresh token vs httpOnly cookie)
- Route protection pattern (middleware, wrapper, guard)
Output Artifact
Complete auth integration: provider config, auth hook/context, protected route component, token management, login/logout flows.
Response Format
## Strategy
<auth-provider, token-storage, route-guard-pattern>
## Setup
<provider-config, auth-context>
## Implementation
<login, logout, token-refresh, protected-routes>
## Session
<persistence, recovery, timeout>
—
Compression footer: frontend-auth/v1 | provider: <provider> | storage: <httpOnly|memory|localStorage> | routes: <count>
No preamble. No postamble. No explanations. No filler/hedging/transitions. Compress output — why use many token when few do trick.
Completion Criteria
- Login flow completes (credentials, OAuth, or magic link)
- Tokens stored securely (httpOnly cookie or in-memory, never localStorage for sensitive apps)
- Route guards redirect unauthenticated users to login
- Token refresh happens transparently before expiry
- Logout clears all local tokens and redirects
- Session persists across page reloads (cookie or refresh token)
- Auth state available globally via context/provider
Max Response Length
4096 tokens
Auth Strategy Decision Trees
Auth Provider Decision Tree
Team size and requirements?
|-- Solo / small team, need quick setup -->
| |-- Want hosted auth UI? --> Clerk or Auth0
| |-- Want database integration? --> Supabase Auth
| |-- Need social login quick? --> Firebase Auth
|-- Mid-size team, need control -->
| |-- Using AWS? --> Cognito
| |-- Need enterprise SSO? --> Auth0 or Azure AD B2C
| |-- Want self-hosted? --> Keycloak or Supertokens
|-- Large enterprise -->
|-- Have identity provider? --> OIDC federation
|-- Building custom? --> Custom JWT with OAuth2
Token Storage Decision Tree
Is the app a production SPA with sensitive data?
|-- YES --> Can the API set httpOnly cookies?
| |-- YES --> httpOnly cookie (best security)
| |-- NO --> In-memory + refresh token rotation
|-- NO --> Is it a low-sensitivity app or prototype?
|-- YES --> localStorage (acceptable for low-risk)
|-- NO --> sessionStorage (tab-scoped, moderate security)
Auth token in localStorage?
|-- Risk: XSS → token theft
|-- Mitigation: short expiry, CSP headers, input sanitization
|-- Recommendation: Never for production banking/health/enterprise apps
Route Protection Strategy Decision Tree
Route type?
|-- Public (landing, marketing, login) → no guard
|-- Authenticated only (dashboard, profile) → auth guard
|-- Role-restricted (admin panel) → auth guard + role/perm check
|-- Guest-only (login/signup when logged in) → redirect to home
Workflow
1. Auth Provider Integration
// Auth0
import { Auth0Provider } from '@auth0/auth0-react'
<Auth0Provider domain="dev-xxx.us.auth0.com" clientId="xxx" authorizationParams={{ redirect_uri: window.location.origin }}>
<App />
</Auth0Provider>
// Supabase
import { createClient } from '@supabase/supabase-js'
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY)
// Custom JWT
const login = async (email: string, password: string) => {
const { accessToken, refreshToken } = await api.post('/auth/login', { email, password })
tokenStorage.set({ accessToken, refreshToken })
}
2. Token Storage Decision
| Storage | Security | Persists Refresh | Use When |
|---|---|---|---|
| httpOnly cookie | Best | Yes | Same-origin API, production apps |
| In-memory | Good | No (must use refresh token) | SPAs with refresh token rotation |
| localStorage with prefix | Moderate | Yes | Low-sensitivity apps, prototyping |
| sessionStorage | Moderate | No (tab-scoped) | Short-lived sessions |
3. Auth Context
interface AuthState {
user: User | null
accessToken: string | null
isAuthenticated: boolean
isLoading: boolean
}
interface AuthActions {
login: (credentials: Credentials) => Promise<void>
logout: () => Promise<void>
getAccessToken: () => Promise<string | null>
}
// Complete auth co
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/auth-flows.md
- references/auth-providers.md
- references/auth-security.md
- references/auth-ui-patterns.md
- references/oauth-pkce-flow.md
- references/token-management.md
FAQ
Что делает скилл frontend-authentication?
Use when the user asks to implement JWT login with refresh tokens in the browser, OAuth2/OIDC with PKCE, protected routes and route guards, token storage, sessions, logout, SSO, passkeys or MFA screens. Produces secure client-side auth flows for any framework and provider. Not for server-side token validation and auth APIs (use backend-auth-patterns).
Как установить скилл frontend-authentication?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл frontend-authentication запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
AnthropicGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
claude-api
AnthropicReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
algorithmic-art
AnthropicCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
mcp-integration
AnthropicThis skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…