Agent skill

Auth Architecture

by majiayu000 in majiayu000/litellm-rs

LiteLLM-RS Authentication Architecture. An agent skill from majiayu000/litellm-rs.

MITAuto-check passedBackend & APIs

Install Auth Architecture

skills CLI
$ npx skills add majiayu000/litellm-rs --skill auth-architecture -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install majiayu000/litellm-rs auth-architecture --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/majiayu000/litellm-rs.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/auth-architecture .claude/skills/auth-architecture && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
auth-architecture
GitHub stars
118
Token cost
~1.9k tokens
SKILL.md length
483 words
Files
7
Skills in repo
9
Repo updated
First seen
Licence
MIT

At a glance

LiteLLM-RS Authentication Architecture. An agent skill from majiayu000/litellm-rs.

  • Works in 6 steps: Authorization: Bearer → AuthMethod::Jwt → Authorization: ApiKey → AuthMethod::ApiKey → Authorization: gw-... (raw key, no… → …
  • Adding auth methods
  • SKILL.md covers Overview, Credential Extraction, API Key Authentication and JWT Authentication, plus 1 more section
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Auth Architecture is an agent skill from majiayu000/litellm-rs. LiteLLM-RS Authentication Architecture. Covers JWT + API Key + RBAC multi-method auth, DashMap-backed rate limiting, the actix-web middleware pipeline, and credential management (gw- prefixed keys, HMAC hashing). Use when adding auth methods, debugging JWT/API-key validation, implementing RBAC permission checks, or tuning rate limiting and auth configuration.

Its SKILL.md is about 1.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 7 other files (for example `reference/configuration.md`, `reference/error-types.md` and `reference/middleware-pipeline.md`).

It sits in Backend & APIs, covering Authentication, Authorization and RBAC and Model routing and gateways. It works with OpenAI and Rust. The repository describes itself as: Self-hosted Rust LLM gateway with OpenAI-compatible APIs, load balancing, failover, and a reusable Rust kernel. The licence is MIT.

When your agent uses it

  • Adding auth methods
  • Debugging JWT/API-key validation
  • Implementing RBAC permission checks
  • Tuning rate limiting and auth configuration

Example prompts

  • “/auth-architecture”

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Authorization: Bearer → AuthMethod::Jwt
  2. Authorization: ApiKey → AuthMethod::ApiKey
  3. Authorization: gw-... (raw key, no scheme) → AuthMethod::ApiKey
  4. Configured API key header (auth.api_key_header, default Authorization)
  5. X-API-Key fallback (when the configured header differs)
  6. session= cookie → AuthMethod::Session

What it can do on your machine

Read from SKILL.md and the folder at commit ed3f4d9. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are rust).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Auth Architecture loads about 1.9k tokens when it runs. Until then it costs about 95 tokens; SKILL.md has 483 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~95
When it runs · the whole SKILL.md, loaded when a task matches
~1.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from majiayu000/litellm-rs at commit ed3f4d9, republished under its MIT licence (© majiayu000). 483 words, ~1,908 tokens.

Download SKILL.mdSave it as .claude/skills/auth-architecture/SKILL.md (or your agent's skills folder). This skill also uses 6 other files; get the full folder from GitHub.
name
auth-architecture
description
LiteLLM-RS Authentication Architecture. Covers JWT + API Key + RBAC multi-method auth, DashMap-backed rate limiting, the actix-web middleware pipeline, and credential management (gw- prefixed keys, HMAC hashing). Use when adding auth methods, debugging JWT/API-key validation, implementing RBAC permission checks, or tuning rate limiting and auth configuration.

Authentication Architecture Guide

Overview

AuthSystem (src/auth/system.rs) composes three subsystems behind one authenticate() entry point:

rust
pub struct AuthSystem {
    config: Arc<AuthConfig>,
    storage: Arc<StorageLayer>,
    jwt: Arc<JwtHandler>,        // src/auth/jwt/types.rs
    api_key: Arc<ApiKeyHandler>, // src/auth/api_key/creation.rs
    rbac: Arc<RbacSystem>,       // src/auth/rbac/system.rs
}

AuthSystem::authenticate(auth_method, context) -> Result<AuthResult> dispatches on AuthMethod::{Jwt, ApiKey, Session, None} (src/auth/types.rs). Session auth is a stub that always rejects ("Session authentication is not yet implemented"). Semantic rejections return AuthResult { success: false, error: Some(..) }; infrastructure failures return Err(GatewayError).

Middleware pipeline

Wired in src/server/http.rs (actix runs wraps in reverse registration order, so the request path is outermost-first):

RequestIdMiddleware -> AuditMiddleware -> IpAccessMiddleware -> CORS/Metrics
  -> AuthMiddleware            (src/server/middleware/auth.rs)
  -> RateLimitMiddleware       (src/server/middleware/rate_limit.rs)
  -> SecurityHeadersMiddleware -> handler

AuthMiddleware per request: public-route bypass → fail-closed check when both auth methods are disabled (allow_anonymous gate) → brute-force lockout via AuthRateLimiter → credential extraction → authentication → endpoint/operation authorization → insert User / ApiKey into request extensions.


Credential Extraction

extract_auth_method_with_api_key_header (src/server/middleware/helpers.rs) resolves credentials in this priority order:

  1. Authorization: Bearer <jwt> → AuthMethod::Jwt
  2. Authorization: ApiKey <key> → AuthMethod::ApiKey
  3. Authorization: gw-... (raw key, no scheme) → AuthMethod::ApiKey
  4. Configured API key header (auth.api_key_header, default Authorization)
  5. X-API-Key fallback (when the configured header differs)
  6. session=<id> cookie → AuthMethod::Session

There is no Bearer sk- form: gateway keys are gw- prefixed, and a raw sk-... value matches nothing.

API Key Authentication

Key generation and hashing

Keys are generated by generate_api_key() in src/utils/auth/crypto/keys.rs: a fixed gw prefix plus 32 alphanumeric characters (gw-<32 chars>, 35 total). They are hashed — never stored in plaintext:

rust
// src/utils/auth/crypto/keys.rs
pub fn generate_api_key() -> String;                       // "gw-" + 32 alphanumerics
pub fn hash_api_key(api_key: &str, hmac_secret: Option<&str>) -> String;
pub fn extract_api_key_prefix(api_key: &str) -> String;    // "gw-a...mnop" display only

hash_api_key computes HMAC-SHA256 when api_key_hmac_secret is configured, otherwise plain SHA-256. Argon2 is used only for user passwords (src/utils/auth/crypto/password.rs), never for API keys.

Handler

ApiKeyHandler::new(storage: Arc<StorageLayer>, hmac_secret: Option<String>) stores keys through the database layer and looks them up by full hash (find_api_key_by_hash) — there is no prefix lookup.

rust
impl ApiKeyHandler {
    pub async fn create_key(&self, user_id: Option<Uuid>, team_id: Option<Uuid>,
        name: String, permissions: Vec<String>) -> Result<(ApiKey, String)>; // (stored, raw)
    pub async fn verify_key(&self, raw_key: &str) -> Result<Option<(ApiKey, Option<User>)>>;
    pub async fn verify_key_detailed(&self, raw_key: &str) -> Result<ApiKeyVerification>;
}

Verification rejects inactive or expired keys and keys whose owner user is missing/inactive; it refreshes last_used_at throttled to once per 5 minutes (LAST_USED_THROTTLE) via an in-memory DashMap<Uuid, Instant> cache. Names must be 1–255 chars without control characters; permissions must be from VALID_PERMISSIONS (creation.rs): *, system.admin, analytics.read, api.chat, api.embeddings, api.images, and dotted read/write/delete grants on users, teams, api_keys (e.g. users.read, api_keys.delete). Management lives on the same handler: revoke_key, list_user_keys, update_permissions, update_expiration, regenerate_key (returns a new raw key), cleanup_expired_keys (src/auth/api_key/management.rs).

Show full SKILL.md (163 more words)Show less

JWT Authentication

Claims

Single role: String (not a role list), plus token identity fields (src/auth/jwt/types.rs):

rust
pub struct Claims {
    pub sub: Uuid,                  // user ID
    pub iat: u64, pub exp: u64,
    pub iss: String,                // fixed "litellm-rs"
    pub aud: String,                // "api" for access, "refresh" for refresh tokens
    pub jti: String,                // UUID token ID
    pub role: String,
    pub permissions: Vec<String>,
    pub team_id: Option<Uuid>,
    pub session_id: Option<String>,
    pub token_type: TokenType,      // Access | Refresh | PasswordReset |
}                                   // EmailVerification | Invitation
Handler

JwtHandler::new(config: &AuthConfig) builds HS256 signing keys from jwt_secret; lifetime comes from jwt_expiration. There is no configurable audience field — audiences are hard-coded per token kind.

rust
impl JwtHandler {
    pub async fn create_access_token(&self, user_id: Uuid, role: String,
        permissions: Vec<String>, team_id: Option<Uuid>, session_id: Option<Uuid>)
        -> Result<String>;
    pub async fn create_refresh_token(&self, user_id: Uuid,
        session_id: Option<String>) -> Result<String>;      // exp = expiration * 24
    pub async fn create_token_pair(...) -> Result<TokenPair>;
    pub async fn verify_access_token(&self, token: &str) -> Result<Claims>;
    pub async fn verify_refresh_token(&self, token: &str) -> Result<Uuid>;
}

For both public creation methods, team_id must currently be None; passing Some(...) returns BadRequest("Active team selection requires verified membership"). Team-scoped access tokens and token pairs are created only through the crate-private create_access_token_for_verified_team / create_token_pair_for_verified_team paths after active membership has been verified.

verify_access_token enforces aud == "api" and rejects unknown team-scope versions; verify_refresh_token enforces aud == "refresh" plus token_type == Refresh. JWT decode failures map to GatewayError::Auth("JWT error: ...").

References

© majiayu000, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 6 other files in .claude/skills/auth-architecture of majiayu000/litellm-rs.

  • SKILL.md
  • reference/configuration.md
  • reference/error-types.md
  • reference/middleware-pipeline.md
  • reference/rate-limiting.md
  • reference/rbac.md
  • reference/security-best-practices.md

Open the folder on GitHubat commit ed3f4d9

Compare with similar skills

Auth Architecture next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Auth Architecture compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Auth Architecture this skillmajiayu000/litellm-rs118—~1.9kAutomated safety check: PassMIT
API Auditbriiirussell/cybersecurity-skills413—~2.8kAutomated safety check: NotesMIT
Springboot Securityaffaan-m/ECC277k5 repos~2kAutomated safety check: PassMIT
API Security Designvinayaklatthe/microsoft-security-skills175—~2.2kAutomated safety check: PassMIT
Laravel Securityaffaan-m/ECC277k3 repos~2kAutomated safety check: PassMIT
API Security Best Practicesdavila7/claude-code-templates33k8 repos~5.8kAutomated safety check: PassMIT

Similar skills

  • API Audit

    briiirussell/cybersecurity-skills

    Audit REST, GraphQL, and RPC APIs against the OWASP API Security Top 10 (2023).

    413 GitHub stars~2.8k tokensUpdated 4 mo ago
    Backend & APIsAuto-check: notes
  • Spring Security best practices for authn/authz, validation, CSRF, secrets, headers, rate limiting, and dependency security in Java Spring Boot services.

    277k GitHub starsUsed in 5 repos~2k tokens
    Backend & APIsAuto-check passed
  • API Security Design

    vinayaklatthe/microsoft-security-skills

    Guidance for designing secure APIs on Azure - authentication, authorization, gateway controls, input validation, rate limiting, secret management, and runtime threat detection - aligned to OWASP API…

    175 GitHub stars~2.2k tokensUpdated 3 mo ago
    Backend & APIsAuto-check passed
  • Laravel Security

    affaan-m/ECC

    Laravel security best practices for authn/authz, validation, CSRF, mass assignment, file uploads, secrets, rate limiting, and secure deployment.

    277k GitHub starsUsed in 3 repos~2k tokens
    Backend & APIsAuto-check passed
  • API Security Best Practices

    davila7/claude-code-templates

    Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities

    33k GitHub starsUsed in 8 repos~5.8k tokens
    Backend & APIsAuto-check passed
  • Discover API

    rand/cc-polymath

    Automatically discover API design skills when working with REST APIs, GraphQL schemas, API authentication, OAuth, JWT, rate limiting, API versioning, error handling, or endpoint design.

    181 GitHub stars~1.5k tokensUpdated 7 mo ago
    Backend & APIsAuto-check passed

More from majiayu000/litellm-rs

All 9 skills in this repo
  • Caching Architecture

    majiayu000/litellm-rs

    LiteLLM-RS response caching architecture. An agent skill from majiayu000/litellm-rs.

    118 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Config Architecture

    majiayu000/litellm-rs

    LiteLLM-RS Configuration Architecture. An agent skill from majiayu000/litellm-rs.

    118 GitHub stars~3.2k tokensUpdated today
    Auto-check passed
  • Error Handling

    majiayu000/litellm-rs

    LiteLLM-RS Error Handling Architecture. An agent skill from majiayu000/litellm-rs.

    118 GitHub stars~2k tokensUpdated today
    Auto-check passed
  • Observability Architecture

    majiayu000/litellm-rs

    LiteLLM-RS Observability Architecture. An agent skill from majiayu000/litellm-rs.

    118 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Provider Architecture

    majiayu000/litellm-rs

    LiteLLM-RS provider system in two tiers - data-driven OpenAI-compatible catalog entries auto-routed through OpenAILikeProvider, plus code-based provider modules implementing the LLMProvider trait…

    118 GitHub stars~4.9k tokensUpdated today
    Auto-check passed
  • Routing Architecture

    majiayu000/litellm-rs

    LiteLLM-RS Routing Architecture. An agent skill from majiayu000/litellm-rs.

    118 GitHub stars~1.9k tokensUpdated today
    Auto-check passed

Works with

Categories

Questions about Auth Architecture

What does Auth Architecture do?

LiteLLM-RS Authentication Architecture. An agent skill from majiayu000/litellm-rs. Auth Architecture is an agent skill from majiayu000/litellm-rs. LiteLLM-RS Authentication Architecture.

When should I use Auth Architecture?

Auth Architecture fits situations like: adding auth methods; debugging JWT/API-key validation; implementing RBAC permission checks; tuning rate limiting and auth configuration.

How do I install Auth Architecture in Claude Code?

Run `npx skills add majiayu000/litellm-rs --skill auth-architecture -a claude-code`. Or copy the skill folder (.claude/skills/auth-architecture in majiayu000/litellm-rs) into .claude/skills/auth-architecture in your project. Claude Code loads it when a task matches its description.

How do I install Auth Architecture in Codex?

Run `npx skills add majiayu000/litellm-rs --skill auth-architecture -a codex`. Or copy the skill folder (.claude/skills/auth-architecture in majiayu000/litellm-rs) into .agents/skills/auth-architecture in your project. Codex loads it when a task matches its description.

Can I use Auth Architecture in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add majiayu000/litellm-rs --skill auth-architecture -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/auth-architecture, .gemini/skills/auth-architecture, .github/skills/auth-architecture and .opencode/skills/auth-architecture in your project.

What does Auth Architecture need to run?

SKILL.md names no scripts, command-line tools or credentials: Auth Architecture is instructions for the agent only.

Does Auth Architecture access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Auth Architecture safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Auth Architecture use?

Auth Architecture is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Auth Architecture use?

About 1.9k tokens (SKILL.md is roughly 7.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Auth Architecture?

Skills that share tags, products or a category with Auth Architecture: API Audit (briiirussell/cybersecurity-skills, 413 stars), Springboot Security (affaan-m/ECC, 277k stars), API Security Design (vinayaklatthe/microsoft-security-skills, 175 stars) and Laravel Security (affaan-m/ECC, 277k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Auth Architecture?

majiayu000 (a GitHub user) maintains it in majiayu000/litellm-rs, which has 118 GitHub stars. The repository holds 9 skills in this directory. The repository was last updated on October 11, 2026.

Source: majiayu000/litellm-rs on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.