# Auth and rbac

> Auth and rbac is an open-source agent skill for security. Guides FastAPI auth with session or JWT chains, argon2id hashing, MFA and RBAC. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/ajyadav013/claude-kit/tree/main/providers/codex/claude-kit/skills/auth-and-rbac
- **Repository:** https://github.com/ajyadav013/claude-kit
- **GitHub stars:** 13
- **License:** MIT
- **Skill name:** auth-and-rbac
- **Collection:** https://github.com/ajyadav013/claude-kit
- **Categories:** [security](https://ai-powered.com/categories/security), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-03

## About

This skill gives the agent a reference set of FastAPI authentication and authorization patterns drawn from identity services and multi-tenant backends. It covers session and JWT dependency chains, RS256 token issuance with key rotation and a JWKS endpoint, refresh token rotation, and argon2id password hashing run off the event loop. It also covers MFA with TOTP and email one-time codes, backup codes, and a role hierarchy with org and subtree access checks.

The material is organized as conventions, code skeletons and anti-patterns, with separate reference files for dependencies, RBAC, token and hashing details, and security hardening such as rate limiting, lockout and session fingerprinting. It also explains when to choose RBAC, ABAC or ACL models and outlines an OAuth 2.0 authorization-code flow with PKCE and state checks for social login.

The skill is Python and FastAPI oriented and expects libraries such as argon2, pyjwt, pyotp and Redis to be available in the project. It ships no scripts; the agent applies the patterns to the code it is writing.

## When your agent uses it

> FastAPI auth patterns — session/JWT chains, argon2id hashing, pyotp TOTP/Email OTP, role-based access control, x-user-data gateway forwarding. Use when building auth dependencies, MFA, or role hierarchies.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/ajyadav013/claude-kit/tree/HEAD/providers/codex/claude-kit/skills/auth-and-rbac)
- [License: MIT](https://github.com/ajyadav013/claude-kit/tree/HEAD/providers/codex/claude-kit/skills/auth-and-rbac)

## Features

- **Session and JWT chains:** Dependency patterns for cookie sessions and bearer token authentication in FastAPI.
- **Password hashing with argon2id:** Argon2id parameters and async wrappers so hashing does not block the event loop.
- **RS256 token issuance:** Signed access tokens with key IDs, refresh token rotation and a JWKS endpoint.
- **MFA with TOTP and email codes:** Setup and verification flows for authenticator apps, email one-time codes and backup codes.
- **Role hierarchy and org checks:** Role dependencies and materialized-path checks for admins managing org subtrees.
- **Gateway identity forwarding:** Parsing a forwarded x-user-data header and the trust boundary it requires.

## Good for

- Add login with JWT access and refresh tokens to a FastAPI service
- Protect admin endpoints with role-based dependencies
- Add TOTP or email one-time code MFA to an existing login flow
- Hash and verify user passwords with argon2id in an async app
- Restrict tenant and org admins to their own organization subtree

## Install

### Claude Code

This skill ships in the `claude-kit` plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

```sh
/plugin marketplace add ajyadav013/claude-kit
/plugin install claude-kit@claude-kit
```

Or copy only this skill to `~/.claude/skills/auth-and-rbac`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/auth-and-rbac &&
cp -R "$tmp/providers/codex/claude-kit/skills/auth-and-rbac" ~/.claude/skills/auth-and-rbac &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/auth-and-rbac` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/auth-and-rbac` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/auth-and-rbac &&
cp -R "$tmp/providers/codex/claude-kit/skills/auth-and-rbac" ~/.agents/skills/auth-and-rbac &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/auth-and-rbac` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/auth-and-rbac` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/auth-and-rbac &&
cp -R "$tmp/providers/codex/claude-kit/skills/auth-and-rbac" ~/.cursor/skills/auth-and-rbac &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/auth-and-rbac` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/ajyadav013/claude-kit.git --path providers/codex/claude-kit/skills/auth-and-rbac
```

Or copy the folder to `~/.gemini/skills/auth-and-rbac` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/auth-and-rbac`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/auth-and-rbac &&
cp -R "$tmp/providers/codex/claude-kit/skills/auth-and-rbac" ~/.copilot/skills/auth-and-rbac &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/auth-and-rbac` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/ajyadav013/claude-kit.git
```

Then copy `claude-kit/providers/codex/claude-kit/skills/auth-and-rbac` into your agent's skills folder as `auth-and-rbac`. Agents that support SKILL.md read one folder per skill.

## FAQ

### What does Auth and rbac need to be used?

It is written for FastAPI projects and references argon2, pyjwt, pyotp, Redis and Fernet-encrypted storage in its examples.

### Does Auth and rbac install any scripts or change files?

No. It has no scripts; it provides guidance and code patterns the agent can apply when building auth code.

### When does Auth and rbac trigger?

It is meant for tasks involving building auth dependencies, multi-factor authentication or role hierarchies in FastAPI.

### Which authorization model does Auth and rbac recommend?

It describes RBAC as the default for a small set of org-wide tiers, and suggests ABAC-style ownership checks or ACLs when rules depend on ownership or per-object sharing.

### How do I install Auth and rbac in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/auth-and-rbac to use it in all your projects, or to .claude/skills/auth-and-rbac in one project. Or install the claude-kit plugin, which includes it: /plugin marketplace add ajyadav013/claude-kit, then /plugin install claude-kit@claude-kit.

### Does Auth and rbac run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Auth and rbac?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Auth and rbac?

The closest alternatives to Auth and rbac are Auth security, Sh kb auth, API security auth pattern, Authentication and Backend repo architecture.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Auth security](https://ai-powered.com/skills/auth-security): Auth security is an open-source agent skill for security.
- [Sh kb auth](https://ai-powered.com/skills/sh-kb-auth): Sh kb auth is an open-source agent skill for security.
- [API security auth pattern](https://ai-powered.com/skills/api-security-auth-pattern): API security auth pattern is an open-source agent skill for security.
- [Authentication](https://ai-powered.com/skills/authentication): Authentication is an open-source agent skill for security.
- [Backend repo architecture](https://ai-powered.com/skills/backend-repo-architecture): Backend repo architecture is an open-source agent skill for developer tools.
- [Async python patterns](https://ai-powered.com/skills/async-python-patterns): Async python patterns is an open-source agent skill for developer tools.
- [Python backend](https://ai-powered.com/skills/python-backend): Python backend is an open-source agent skill for developer tools.
- [Implementing hardware security key authentication](https://ai-powered.com/skills/implementing-hardware-security-key-authentication): Implementing hardware security key authentication is an open-source agent skill for security.

---
Source: https://ai-powered.com/skills/auth-and-rbac
