Authentication
Skill kent8192/reinhardt-agents-plugin/plugins/reinhardt-agents-plugin/skills/authentication
Use when configuring authentication in reinhardt-web applications - covers auth backends (JWT, Session, Token, OAuth2/Social), user models, password hashing, and session managementFrom its SKILL.md
npx -y skills add kent8192/reinhardt-agents-plugin --skill authenticationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
6.2 KB, as published. Nobody here has run it
Reinhardt Authentication
Guide developers through authentication setup using reinhardt-auth, including backend configuration, user models, password hashing, and session management.
When to Use
- User configures or selects an authentication backend
- User defines or customizes a user model
- User works with login/logout flows
- User configures JWT, session, token, or OAuth2/social authentication
- User asks about password hashing or session management
- User mentions: "auth", "authentication", "login", "logout", "JWT", "token", "session", "password", "OAuth", "social login", "Google login", "GitHub login", "BasicAuth", "CurrentUser", "AuthUser", "AuthInfo", "user model", "BaseUser", "createsuperuser"
Workflow
Choosing an Auth Backend
- Read
references/auth-backends.mdfor backend comparison - Select backend based on use case (JWT for APIs, Session for web apps, Social for third-party login)
- Enable the corresponding feature flag in
Cargo.toml - Configure via
#[injectable]providers — read DI skill for keyed provider patterns
Defining a Custom User Model
- Read
references/user-models.mdfor trait hierarchy and field requirements - Define struct with
#[model]and#[user]attributes - Implement
BaseUsertrait (or use#[user]macro for auto-implementation) - Choose password hasher (Argon2 recommended for production)
- Register user model in app configuration
Planning a Password Hash Upgrade (0.4.x)
- Select one preferred hasher for newly created passwords (normally
Argon2Hasherwith theargon2-hasherfeature). - Build
PasswordHashPolicywith that preferred hasher, then add each deployed legacy format withwith_legacy(...)in its required verification order. - At login, call
BaseUser::check_password_with_policy_updateon a mutable user. It recognizes valid legacy or stale preferred hashes and returns aPasswordCheckstatus. - Persist the changed user only after
PasswordCheck::ValidUpdated; use a conditional or optimistic update based on the prior password hash or record version so a rehash cannot overwrite a concurrent password change. - Cover current hashes, each legacy format, stale parameters, invalid credentials, rehash failures, and concurrent password updates in tests.
Setting Up Auth Extractors
- Read
../authorization/references/extractors.mdforAuthInfoandCurrentUser<T> - Use
AuthInfofor lightweight access (no DB query) - Use
CurrentUser<T>when the full user model is needed - Both require
#[inject]in handler parameters
Configuring Social/OAuth2 Login
- Read
references/social-auth.mdfor provider setup - Configure
ProviderConfigfor each provider (Google, GitHub, Apple, Microsoft) - Set up
SocialAuthBackendwith PKCE and state validation - Map OAuth claims to user model via
UserMapper
Session Management
- Read
references/session-management.mdfor backend options - Choose session backend (Database, Cache, Cookie, JWT, File, InMemory)
- Configure session settings (cookie, expiry, security)
- Set up cleanup and rotation if needed
Important Rules
- ALWAYS use
argon2-hasherfor newly created production password hashes - NEVER replace a deployed password algorithm without a
PasswordHashPolicythat can verify the stored legacy hashes PasswordHashPolicyverifies its preferred hasher first and then legacy hashers in registration order; valid legacy or stale hashes may produce a replacement hashcheck_password_with_policy_updatechanges only the in-memory user value. Persist onlyPasswordCheck::ValidUpdated, using a conditional write when authentication can race with password changes or resets- Do not reject a valid login solely because its opportunistic rehash fails
BcryptHasheris opt-in throughbcrypt-hasher, may be selected as either a preferred or legacy policy hasher, and has a 72-byte password limit- NEVER store secrets (JWT keys, OAuth client secrets) in code — use environment variables
AuthInfois lightweight (reads from request extensions) — use when you only need user IDCurrentUser<T>loads the full user model from DB — use when you need user fieldsAuthUser<T>is removed in 0.3.x — migrate old code toCurrentUser<T>- Register
SessionMiddlewareonce for cookie-backed session apps; useCookieSessionAuthMiddlewareonly for direct customAsyncSessionBackendintegration - In 0.3.x,
#[user]is inert on WASM, so shared user model declarations should stay visible to browser builds without broad call-site#[cfg]workarounds - Feature flags:
auth-jwt,auth-session,auth-token,auth-oauth,argon2-hasher,bcrypt-hasher,social - JWT access token lifetime should be short (15 min recommended); use refresh tokens for longer sessions
- Session cookies MUST use
HttpOnly,SameSite, andSecure(in production)
Cross-Domain References
- For DI configuration of auth backends:
../dependency-injection/references/di-patterns.md - For permission and authorization setup:
../authorization/SKILL.md - For auth in API endpoints:
../api-development/references/auth-config.md - For user model definition with
#[model]:../macros/references/attribute-macros.md
Dynamic References
For the latest auth API:
- Read
reinhardt/crates/reinhardt-auth/src/lib.rsfor module structure and re-exports - Read
reinhardt/crates/reinhardt-auth/src/core/base_user.rsfor BaseUser trait - Read
reinhardt/crates/reinhardt-auth/src/core/hasher.rsfor password policies and hasher contracts - Read
reinhardt/crates/reinhardt-auth/src/basic.rsforHttpBasicAuthpolicy behavior - Read
reinhardt/crates/reinhardt-auth/src/jwt.rsfor JWT types - Read
reinhardt/crates/reinhardt-auth/src/rest_authentication.rsfor REST auth backends - Read
reinhardt/crates/reinhardt-auth/src/social.rsfor social auth module - Read
reinhardt/crates/reinhardt-auth/src/sessions/for session backends - Grep for
#[user]inreinhardt/tests/for real user model examples