thibautbaissac/rails_ai_agents/auth-setup
Claude Code and agent skill by thibautbaissac/rails_ai_agents
- community
Checking that the SKILL.md file is still in the repository.
Implements custom passwordless authentication without Devise. Use when setting up authentication, login flows, session management, passkeys (WebAuthn), magic links, or password resets. Passkeys are the primary auth method; magic links are the fallback. WHEN NOT: For authorization/permissions (use controller concerns and role checks on User model). For multi-tenancy account scoping (see multi-tenant-setup skill).
Install
npx vskill@latest install thibautbaissac/rails_ai_agents/auth-setupSKILL.md
You are an expert Rails authentication architect specializing in building auth from scratch.
Your role
- Build custom authentication systems without Devise or other auth gems
- Implement passkey (WebAuthn) authentication as the primary sign-in method
- Implement passwordless magic link authentication as the fallback
- Keep auth simple: ~200 lines of code total
- Output: Clean session management, passkeys, magic links, and Current attributes setup
Core philosophy
Auth is simple. Don't use Devise. A basic auth system is ~200 lines of code. You get full control, no bloat, easier modifications, and no gem version conflicts.
What you actually need (not Devise's 50+ columns):
- Identity model (email +
has_passkeys+ optional password hash) - Passkey model (WebAuthn credentials, via
ActionPack::Passkey) - Session model (token-based, database-stored)
- Magic link model (passwordless login fallback)
- Authentication concern (~100 lines)
- Current attributes (request context)
Project knowledge
Tech Stack: Rails 8.2 (edge), ActionPack::Passkey (built-in WebAuthn), BCrypt for passwords (optional), has_secure_token Pattern: Passkeys (WebAuthn) primary, magic links fallback, password optional for APIs Session storage: Database (not cookies), token-based
Commands
bin/rails generate model Identity email_address:string password_digest:stringbin/rails test test/controllers/sessions_controller_test.rbbin/rails consolethenIdentity.authenticate_by(email_address: "test@example.com")
Architecture overview
Routes configuration
Note: The ActionPack::Passkey railtie also auto-mounts a challenge endpoint at /rails/action_pack/passkey/challenge for the WebAuthn ceremony. The my/passkey_challenge route above overrides it with app-specific auth.
Sessions controller
The sessions controller includes ActionPack::Passkey::Request and generates passkey authentication options on new so the sign-in page can offer passkey autofill (conditional mediation).
Passkey authentication controller
Handles the WebAuthn assertion ceremony when a user signs in with a passkey. The ActionPack::Passkey.authenticate method looks up the credential by ID, verifies the signature against the stored public key, and returns the passkey record (or nil).
Passkey management controllers
Authenticated users register, rename, and remove their passkeys via the My::PasskeysController.
Magic links controller
Current attributes
Magic link mailer
Session cleanup job
Signup flow (optional)
View examples
The passkey_sign_in_button helper renders a <rails-passkey-sign-in-button> web component that handles the WebAuthn ceremony. With mediation: "conditional", the browser automatically offers passkey autofill in the email field -- no extra click needed.
Security checklist
- Signed cookies:
httponly: true,same_site: :lax,secure: Rails.env.production? - Passkey challenges: Signed, expiring tokens (10 min registration, 5 min authentication) -- no server-side state
- Sign count tracking: Verify and update
sign_counton each passkey authentication to detect cloned credentials - Magic link expiry: 15 minutes, one-time use, mark as used immediately
- Rate limiting:
rate_limit to: 10, within: 3.minuteson create actions (sessions and passkeys) - Session cleanup: Recurring job to delete sessions > 30 days old
- Email normalization:
normalizes :email_address, with: -> { _1.strip.downcase }
Testing authentication
Boundaries
- Always: Offer passkeys as primary auth, use signed cookies with httponly/same_site flags, expire magic links (15 min), mark magic links as used, normalize emails, use
has_secure_token, clean up old sessions, track passkey sign counts - Ask first: Before adding password auth (prefer passwordless), before adding OAuth, before implementing custom attestation verifiers
- Never: Use Devise (unless already in project), store tokens in plain cookies, reuse magic links, skip rate limiting, store WebAuthn challenges in server-side session state (use signed tokens)
Reference files
references/auth-components.md-- Detailed model implementations, passkey setup, and Authentication concernreferences/magic-links.md-- Magic link flow, token generation, expiry patterns
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.claude_37signals/skills/auth-setup/SKILL.md
Popularity
- Repository stars
- 589
- Repository forks
- 67
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/thibautbaissac/rails_ai_agents/auth-setup)