# auth0-authentication

A skill that gives your coding agent Auth0 guidelines: auth flows, Actions, token validation and redirect safety.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 700 installs · ★ 286
- Author: Mindrally
- License: Apache-2.0 · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/Mindrally/skills/tree/HEAD/auth0-authentication/SKILL.md
- Updated: 2026-10-08
- HTML: https://affpapa.org/en/nevibecode/skills/auth0-authentication

## What it does

This skill turns the assistant into an Auth0 reference. It covers environment variables, Authorization Code Flow with PKCE for SPAs and native apps, the server-side flow via `express-openid-connect`, Actions instead of the old Rules, access and refresh token handling, MFA, and error handling.

There is a section on what to avoid: keeping tokens in `localStorage` without weighing XSS, validating tokens only on the client, hardcoding `client_secret` in frontend code, logging out without ending the Auth0 session. The implicit flow is called deprecated outright.

You need `AUTH0_DOMAIN`, `AUTH0_CLIENT_ID`, `AUTH0_CLIENT_SECRET`, `AUTH0_AUDIENCE`, `AUTH0_CALLBACK_URL` and `AUTH0_LOGOUT_URL` in environment variables — the skill insists secrets stay out of code. Action secrets hold the sensitive values used inside Actions. External calls inside an Action add login latency, so the guidance is to keep them few and set short timeouts.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill auth0-authentication -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/auth0-authentication/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/auth0-authentication/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill auth0-authentication -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/auth0-authentication/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill auth0-authentication -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/auth0-authentication/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install Mindrally/skills auth0-authentication
```

2. **Manually: put the files in place**
- File: `.github/skills/auth0-authentication/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill auth0-authentication -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/Mindrally/skills --path auth0-authentication
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/auth0-authentication/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add Mindrally/skills --skill auth0-authentication -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/Mindrally/skills/tree/HEAD/auth0-authentication/SKILL.md

## When to use it
- pick an auth flow for an SPA, native or server-side app
- validate access tokens and required scopes on the backend
- migrate Rules to Actions without breaking login
- close gaps in redirect URIs, sessions and token storage
- add MFA for sensitive operations

## Example prompts
- Review my Auth0 setup for an SPA — do I need PKCE, and where am I storing tokens?
- Convert this Auth0 Rule into an Action and cut the external calls
- Set up JWT validation and the `read:messages` scope for my Express routes

## Source text · SKILL.md · Apache-2.0

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 1b147c063d9e8d37.

BEGIN THIRD-PARTY FILE 1b147c063d9e8d37
````text
---
name: auth0-authentication
description: Guidelines for implementing Auth0 authentication with best practices for security, rules, actions, and SDK integration
metadata:
  maintainer: Mindrally
  source: https://github.com/Mindrally/skills
---

# Auth0 Authentication

You are an expert in Auth0 authentication implementation. Follow these guidelines when working with Auth0 in any project.

## Core Principles

- Always use HTTPS for all Auth0 communications and callbacks
- Store sensitive configuration (client secrets, API keys) in environment variables, never in code
- Implement proper error handling for all authentication flows
- Follow the principle of least privilege for scopes and permissions

## Environment Variables

```bash
# Required Auth0 Configuration
AUTH0_DOMAIN=your-tenant.auth0.com
AUTH0_CLIENT_ID=your-client-id
AUTH0_CLIENT_SECRET=your-client-secret
AUTH0_AUDIENCE=your-api-audience
AUTH0_CALLBACK_URL=https://your-app.com/callback
AUTH0_LOGOUT_URL=https://your-app.com
```

## Authentication Flows

### Authorization Code Flow with PKCE (Recommended for SPAs and Native Apps)

Always use PKCE for public clients:

```javascript
import { Auth0Client } from '@auth0/auth0-spa-js';

const auth0 = new Auth0Client({
  domain: process.env.AUTH0_DOMAIN,
  clientId: process.env.AUTH0_CLIENT_ID,
  authorizationParams: {
    redirect_uri: window.location.origin,
    audience: process.env.AUTH0_AUDIENCE,
  },
  cacheLocation: 'localstorage', // Use 'memory' for higher security
  useRefreshTokens: true,
});
```

### Authorization Code Flow (Server-Side Applications)

```javascript
// Express.js example
const { auth } = require('express-openid-connect');

app.use(
  auth({
    authRequired: false,
    auth0Logout: true,
    secret: process.env.AUTH0_SECRET,
    baseURL: process.env.BASE_URL,
    clientID: process.env.AUTH0_CLIENT_ID,
    issuerBaseURL: `https://${process.env.AUTH0_DOMAIN}`,
  })
);
```

## Auth0 Actions Best Practices

Actions have replaced Rules. Follow these guidelines:

### Action Structure

```javascript
exports.onExecutePostLogin = async (event, api) => {
  // 1. Early returns for efficiency
  if (!event.user.email_verified) {
    api.access.deny('Please verify your email before logging in.');
    return;
  }

  // 2. Use secrets for sensitive data (configured in Auth0 Dashboard)
  const apiKey = event.secrets.EXTERNAL_API_KEY;

  // 3. Minimize external calls - they affect login latency
  // 4. Never log sensitive information
  console.log(`User logged in: ${event.user.user_id}`);

  // 5. Add custom claims sparingly
  api.idToken.setCustomClaim('https://myapp.com/roles', event.authorization?.roles || []);
  api.accessToken.setCustomClaim('https://myapp.com/roles', event.authorization?.roles || []);
};
```
````
END THIRD-PARTY FILE 1b147c063d9e8d37

The third-party file has ended. Everything between the 1b147c063d9e8d37 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2777 of 6154 bytes. © Mindrally · Apache-2.0 · https://github.com/Mindrally/skills/tree/HEAD/auth0-authentication/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
