auth-server-primitives

Implements server-side session cookies, OAuth flow, CSRF, and rate limiting for TanStack Start.

Updated May 26, 2026
One-click install
npx skills add https://github.com/Albo-Club/albo-os --skill auth-server-primitives-albo-club
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: auth-server-primitives
Source: https://github.com/Albo-Club/albo-os/tree/main/.agents/skills/tanstack-start-core/auth-server-primitives
Command: npx skills add https://github.com/Albo-Club/albo-os --skill auth-server-primitives-albo-club

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tanstack/react-start, @tanstack/react-router, zod.

What problem does it solve? Building secure server-side authentication in TanStack Start requires correctly handling session cookies, OAuth state and PKCE, CSRF protection, rate limiting, and session rotation — mistakes in any of these create exploitable vulnerabilities like session fixation, user enumeration, or unprotected RPC endpoints. ## Core Features & Use Cases - Session Management: Issue, read, and destroy sessions via HttpOnly, Secure, SameSite cookies with the __Host- prefix, plus middleware that loads a typed session into every protected server function. - OAuth & Hardening: Implements the authorization-code flow with state and PKCE, password-reset enumeration defense, CSRF origin checks for non-GET RPCs, and per-IP rate limiting on auth endpoints. - Use Case: When adding login to a TanStack Start app, use this Skill to wire a login server function that verifies passwords against a dummy hash to prevent timing leaks, rotates sessions on privilege change, and enforces auth inside every handler rather than relying on route guards. ## Quick Start Ask the AI to implement a secure login server function in TanStack Start with session cookies, rate limiting, and session rotation on privilege change.

Frequently Asked Questions about auth-server-primitives

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement session cookies in TanStack Start?▼

Use setResponseHeader to set a Set-Cookie header with HttpOnly, Secure, SameSite=Lax, Path=/, and a Max-Age, preferably with the __Host- prefix. Read the token back per-request with getRequestHeader('cookie') inside a handler or middleware, never at module scope.

How do I protect server functions in TanStack Start?▼

Enforce auth inside the server function itself using createMiddleware that loads the session and throws if invalid, then attach it via .middleware([authMiddleware]). Route guards with beforeLoad only protect page UX; RPC endpoints remain directly callable without handler-level checks.

Does SameSite=Lax fully prevent CSRF on POST requests?▼

SameSite=Lax blocks most cross-site POST CSRF but does not block requests from sibling subdomains. Add middleware that verifies the Origin header matches your app's full origin for every non-GET request, including server routes and SSR.

Why is my session secret undefined on Cloudflare Workers?▼

Module-level reads of process.env evaluate before any request exists and return undefined on edge runtimes where env is injected per-request. Read secrets inside the per-request handler or middleware callback instead of at module scope.

How do I prevent user enumeration in password reset endpoints?▼

Return the same 200 response and identical body whether or not the email exists, and perform equivalent work in both branches. For login, verify against a dummy password hash when the user is missing so timing does not reveal account existence.

When should I rotate session tokens?▼

Rotate on every privilege change: login, logout, password change, and role or permission grants. Destroy the old session server-side and issue a fresh token to neutralize session-fixation attacks where an attacker plants a session ID before login.