agentsclimarketplace

Authentication

Skill kent8192/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

Install
npx -y skills add kent8192/reinhardt-agents-plugin --skill authentication

Assembled 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

  1. Read references/auth-backends.md for backend comparison
  2. Select backend based on use case (JWT for APIs, Session for web apps, Social for third-party login)
  3. Enable the corresponding feature flag in Cargo.toml
  4. Configure via #[injectable] providers — read DI skill for keyed provider patterns

Defining a Custom User Model

  1. Read references/user-models.md for trait hierarchy and field requirements
  2. Define struct with #[model] and #[user] attributes
  3. Implement BaseUser trait (or use #[user] macro for auto-implementation)
  4. Choose password hasher (Argon2 recommended for production)
  5. Register user model in app configuration

Planning a Password Hash Upgrade (0.4.x)

  1. Select one preferred hasher for newly created passwords (normally Argon2Hasher with the argon2-hasher feature).
  2. Build PasswordHashPolicy with that preferred hasher, then add each deployed legacy format with with_legacy(...) in its required verification order.
  3. At login, call BaseUser::check_password_with_policy_update on a mutable user. It recognizes valid legacy or stale preferred hashes and returns a PasswordCheck status.
  4. 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.
  5. Cover current hashes, each legacy format, stale parameters, invalid credentials, rehash failures, and concurrent password updates in tests.

Setting Up Auth Extractors

  1. Read ../authorization/references/extractors.md for AuthInfo and CurrentUser<T>
  2. Use AuthInfo for lightweight access (no DB query)
  3. Use CurrentUser<T> when the full user model is needed
  4. Both require #[inject] in handler parameters

Configuring Social/OAuth2 Login

  1. Read references/social-auth.md for provider setup
  2. Configure ProviderConfig for each provider (Google, GitHub, Apple, Microsoft)
  3. Set up SocialAuthBackend with PKCE and state validation
  4. Map OAuth claims to user model via UserMapper

Session Management

  1. Read references/session-management.md for backend options
  2. Choose session backend (Database, Cache, Cookie, JWT, File, InMemory)
  3. Configure session settings (cookie, expiry, security)
  4. Set up cleanup and rotation if needed

Important Rules

  • ALWAYS use argon2-hasher for newly created production password hashes
  • NEVER replace a deployed password algorithm without a PasswordHashPolicy that can verify the stored legacy hashes
  • PasswordHashPolicy verifies its preferred hasher first and then legacy hashers in registration order; valid legacy or stale hashes may produce a replacement hash
  • check_password_with_policy_update changes only the in-memory user value. Persist only PasswordCheck::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
  • BcryptHasher is opt-in through bcrypt-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
  • AuthInfo is lightweight (reads from request extensions) — use when you only need user ID
  • CurrentUser<T> loads the full user model from DB — use when you need user fields
  • AuthUser<T> is removed in 0.3.x — migrate old code to CurrentUser<T>
  • Register SessionMiddleware once for cookie-backed session apps; use CookieSessionAuthMiddleware only for direct custom AsyncSessionBackend integration
  • 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, and Secure (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:

  1. Read reinhardt/crates/reinhardt-auth/src/lib.rs for module structure and re-exports
  2. Read reinhardt/crates/reinhardt-auth/src/core/base_user.rs for BaseUser trait
  3. Read reinhardt/crates/reinhardt-auth/src/core/hasher.rs for password policies and hasher contracts
  4. Read reinhardt/crates/reinhardt-auth/src/basic.rs for HttpBasicAuth policy behavior
  5. Read reinhardt/crates/reinhardt-auth/src/jwt.rs for JWT types
  6. Read reinhardt/crates/reinhardt-auth/src/rest_authentication.rs for REST auth backends
  7. Read reinhardt/crates/reinhardt-auth/src/social.rs for social auth module
  8. Read reinhardt/crates/reinhardt-auth/src/sessions/ for session backends
  9. Grep for #[user] in reinhardt/tests/ for real user model examples

Keep looking

Skills are one crate of 607,533. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.