agentleFS
sourjyasourjya/kiro-rails/.claude/skills/auth-implementation/SKILL.md

auth-implementation

Skill9 starsChanged 4 months agoMITView on GitHub

Authentication, SSO, OAuth, OIDC, login, redirect, token implementation patterns. Use when implementing auth flows, login pages, token refresh, SSO integration, or redirect handling.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. 0 are common, 15 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 15

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When implementing any authentication flow, ALL of the following paths must be handled.

    line 8
  2. Distinctive:

    Never fire API requests before confirming token is available

    line 19
  3. Distinctive:

    No token in storage → show login UI or redirect to identity provider

    line 22
  4. Distinctive:

    Don't auto-redirect without checking if a session exists first

    line 23
  5. Distinctive:

    Never redirect from login page back to login page

    line 28
  6. Very specific:

    Cognito: does NOT support prompt=none for silent auth

    line 31
  7. Distinctive:

    Always check provider documentation for supported parameters

    line 34
  8. Distinctive:

    If identity provider is unreachable → show error, don't crash the app

    line 37
  9. Distinctive:

    If OIDC discovery endpoint fails → fall back to manual config or show maintenance page

    line 38
  10. Distinctive:

    Never make the entire app dependent on auth provider availability for rendering

    line 39
  11. Very specific:

    redirect_uri must be dynamic: - use window.location.origin + callback path.

    line 43
  12. Very specific:

    State parameter: - always include a random state param to prevent CSRF.

    line 44
  13. Distinctive:

    Multi-tab sync: - if user logs out in one tab, other tabs should detect it (via storage event or BroadcastChannel).

    line 48
  14. Distinctive:

    Test with expired tokens (mock token expiry)

    line 52
  15. Distinctive:

    Test with identity provider down (mock network failure)

    line 53
  16. Distinctive:

    Test redirect loop scenario (verify max 2 redirects)

    line 54
  17. Distinctive:

    Test multi-tab logout propagation

    line 55
  18. Distinctive:

    Test with clock skew (token appears expired due to time difference)

    line 56

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Auth Implementation Checklist

When implementing any authentication flow, ALL of the following paths must be handled. Do not implement only the happy path.

Mandatory Paths

1. Happy Path

  • User has valid session → proceed normally
  • User authenticates successfully → redirect to intended destination

2. Expired Token

  • Access token expired → attempt silent refresh with refresh token
  • Refresh token expired → redirect to login (not infinite loop)
  • Never fire API requests before confirming token is available

3. Missing Session

  • No token in storage → show login UI or redirect to identity provider
  • Don't auto-redirect without checking if a session exists first

4. Redirect Loop Prevention

  • Max 2 redirects then show an error page with clear message
  • Store redirect count in sessionStorage, reset on successful auth
  • Never redirect from login page back to login page

5. Provider-Specific Quirks

  • Cognito: does NOT support prompt=none for silent auth
  • Keycloak: supports prompt=none but returns login_required error if no session
  • Auth0: supports silent auth via /authorize with prompt=none
  • Always check provider documentation for supported parameters

6. Graceful Degradation

  • If identity provider is unreachable → show error, don't crash the app
  • If OIDC discovery endpoint fails → fall back to manual config or show maintenance page
  • Never make the entire app dependent on auth provider availability for rendering

Implementation Rules

  1. redirect_uri must be dynamic - use window.location.origin + callback path. Never hardcode localhost.
  2. State parameter - always include a random state param to prevent CSRF. Verify it on callback.
  3. Token storage - access tokens in memory (short-lived), refresh tokens in httpOnly cookies or secure storage. Never localStorage for refresh tokens.
  4. Logout must clear ALL state - tokens, cached user info, query cache, any auth-dependent state.
  5. 401 handling - on 401 response, attempt ONE silent refresh. If that fails, redirect to login. Don't retry indefinitely.
  6. Multi-tab sync - if user logs out in one tab, other tabs should detect it (via storage event or BroadcastChannel).

Testing Requirements

  • Test with expired tokens (mock token expiry)
  • Test with identity provider down (mock network failure)
  • Test redirect loop scenario (verify max 2 redirects)
  • Test multi-tab logout propagation
  • Test with clock skew (token appears expired due to time difference)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.