authentication-system-example

authentication-system-example is a cursor rule for Cursor from Hansonli05/Cursor-rules-system. It costs 5 tokens per session (1,392 once invoked), scanned A, original, MIT.

A set of example patterns for adding user login, registration, sessions, and protected pages to an application.

In plain words
What is it for?
Use it when designing or reviewing sign-up, login, logout, session, and access-control flows.
Why use it?
It gives authentication code a consistent structure and highlights security-related steps such as password hashing, token handling, and secure cookies.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when designing or reviewing sign-up, login, logout, session, and access-control flows.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/hansonli05/cursor-rules-system/authentication-system-example
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/Hansonli05/Cursor-rules-system

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for authentication-system-example

README.md
[![agentmods](https://agentmods.dev/badge/rules/hansonli05/cursor-rules-system/authentication-system-example/github.svg)](https://agentmods.dev/rules/hansonli05/cursor-rules-system/authentication-system-example)
Your own site
<a href="https://agentmods.dev/rules/hansonli05/cursor-rules-system/authentication-system-example"><img src="https://agentmods.dev/badge/rules/hansonli05/cursor-rules-system/authentication-system-example/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for authentication-system-example

Your own site · 80×15
<a href="https://agentmods.dev/rules/hansonli05/cursor-rules-system/authentication-system-example"><img src="https://agentmods.dev/badge/rules/hansonli05/cursor-rules-system/authentication-system-example.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 5 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,392 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00005 $0.01392
Opus 5.5 $0.00002 $0.00557
Sonnet 5.5 $0.00001 $0.00278
Haiku 4.5 $0.00001 $0.00139

Measured 2mo ago against content hash b5fc116dc8bc, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

authentication-system-example scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/feature-rules/authentication-system-example.mdc · 226 lines

How it starts

The opening of the file, as written. The whole thing — 226 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Authentication System (Example)

Summary

Defines patterns for implementing user authentication including login, signup, session management, and protected routes. This is an example template - customize for your specific authentication needs.

Context

Authentication is a critical system that requires consistent patterns for security, user experience, and maintainability. This rule ensures all authentication-related code follows established patterns.

Instructions

Authentication Flow

  1. User Registration

    • Collect required user information
    • Validate input data (email format, password strength)
    • Check for existing accounts
    • Create user record with hashed password
    • Send verification email (if required)
    • Auto-login or redirect to login
  2. User Login

    • Validate credentials
    • Generate secure session token/JWT
    • Set secure HTTP-only cookies
    • Redirect to intended destination
    • Handle "remember me" functionality
  3. Session Management

    • Validate tokens on protected routes
    • Refresh tokens before expiration
    • Handle logout (clear tokens/cookies)
    • Manage concurrent sessions

Security Patterns

  • Password Hashing: Use bcrypt or similar secure hashing
  • Token Security: Use JWT with proper expiration and signing
  • HTTPS Only: All authentication requests over HTTPS
  • Rate Limiting: Prevent brute force attacks
  • Input Validation: Sanitize all user inputs
  • CSRF Protection: Implement CSRF tokens for forms

Protected Routes

// Pattern for protected route middleware
function requireAuth(handler: RouteHandler) {
  return async (req, res) => {
    const token = extractTokenFromRequest(req);
    
    if (!token) {
      return res.status(401).json({ error: 'Authentication required' });
    }
    
    try {
      const user = await validateToken(token);
      req.user = user;
      return handler(req, res);
    } catch (error) {
      return res.status(401).json({ error: 'Invalid token' });
    }
  };
}

Read the full file on GitHub · 226 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 226 lines · 5 tokens per session scan A b5fc116dc8bc

Subscribe to this mod's changes

authentication-system-example is a cursor rule published in the GitHub repository Hansonli05/Cursor-rules-system (2 stars, last pushed 1y ago), licensed MIT. It adds 5 tokens to every session and 1,392 once invoked, about $0.0000 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.