grey-haven-authentication-patterns

Implement multi-tenant authentication with better-auth, Redis sessions, and JWT tenant context.

29|4|Updated Aug 10, 2025
One-click install
npx skills add https://github.com/greyhaven-ai/claude-code-config --skill grey-haven-authentication-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: grey-haven-authentication-patterns
Source: https://github.com/greyhaven-ai/claude-code-config/tree/main/grey-haven-plugins/security/skills/authentication-patterns
Command: npx skills add https://github.com/greyhaven-ai/claude-code-config --skill grey-haven-authentication-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and templates (resource) and checklists (resource) and examples (resource) components.

What problem does it solve?

This Skill eliminates the complexity of implementing secure, production-ready authentication systems, saving you weeks of development time and security headaches.

Core Features & Use Cases

  • Multi-Tenant Security: Implement tenant isolation with JWT claims and RLS policies to protect customer data.
  • Multiple Auth Methods: Support email/password, magic links, OAuth providers, and passkeys out of the box.
  • Use Case: Imagine you're launching a new SaaS product. Use this Skill to automatically configure secure user authentication with Google OAuth, magic links, and proper session management - all while ensuring complete tenant isolation.

Quick Start

Configure secure authentication for my TanStack Start app with multi-tenant support using magic links and Google OAuth.

Frequently Asked Questions about grey-haven-authentication-patterns

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

FAQPage Schema
How do I implement multi-tenant authentication with tenant isolation in TanStack Start?

Multi-tenant authentication enforces tenant isolation by embedding tenant_id in JWT claims and applying Row-Level Security policies to users and sessions tables. This Skill configures better-auth with PostgreSQL and Drizzle ORM to automatically propagate tenant context across requests, ensuring each tenant's data remains isolated.

Can I use magic links and OAuth providers with better-auth for authentication?

Yes. This Skill supports multiple authentication methods including email/password, magic links, OAuth providers like Google, and WebAuthn passkeys, all integrated with better-auth. You configure which methods to enable for your TanStack Start application.

How do I manage secrets like OAuth credentials and database connection strings securely?

This Skill integrates Doppler for centralized secret management, storing OAuth credentials, database URIs, and other sensitive configuration outside your codebase. Doppler secrets are injected at runtime into your TanStack Start environment.

Does this authentication pattern work with Redis-backed session storage?

Yes. This Skill configures Redis-based session storage via Upstash, enabling distributed session management across your application instances while maintaining tenant isolation through JWT claims and RLS enforcement.

What's required to set up Row-Level Security for tenant-aware data protection?

Row-Level Security policies are configured in PostgreSQL to enforce tenant_id filtering at the database level. This Skill automates RLS policy creation on users and sessions tables so queries automatically return only the current tenant's data.

Can I use WebAuthn passkeys alongside traditional authentication methods?

Yes. This Skill enables WebAuthn passkey authentication as an alternative to email/password and magic links, all managed by better-auth and stored securely in your PostgreSQL database with tenant context.