authentication-system

Implement dual-token authentication with OAuth and RBAC for Supabase apps.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/bkinsey808/songshare-effect --skill authentication-system
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: authentication-system
Source: https://github.com/bkinsey808/songshare-effect/tree/main/.github/skills/authentication-system
Command: npx skills add https://github.com/bkinsey808/songshare-effect --skill authentication-system

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a secure, scalable authentication model that supports both anonymous visitors and authenticated users within a single Supabase-backed system, enabling safe realtime interactions and effective data access controls.

Core Features & Use Cases

  • Two-Token System: Visitor token for anonymous access and User token for authenticated data operations.
  • Single Supabase Auth User: A unified transport layer to support Realtime with proper differentiation via app_metadata.
  • Dynamic JWT Metadata: app_metadata updated to reflect user context for Row Level Security enforcement.
  • Automatic Token Switching: Client automatically selects and caches the appropriate token based on sign-in state.
  • Row Level Security: Fine-grained access controls across public and private data.
  • In-Memory Token Storage: Client-side caching to avoid localStorage and reduce exposure.

Quick Start

Initialize the client to obtain a visitor token for anonymous access, then switch to a user token after sign-in to enable full data access.

Frequently Asked Questions about authentication-system

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

FAQPage Schema
How do I implement dual-token authentication for anonymous and authenticated users in Supabase?

Dual-token authentication in Supabase uses a visitor token for anonymous access and a user token for authenticated operations. The client automatically switches tokens based on sign-in state, caching them in-memory to manage access securely.

How does Supabase Row Level Security work with realtime JWT metadata?

Row Level Security in Supabase enforces fine-grained data access by evaluating dynamic JWT app_metadata. Updating this metadata reflects the current user context, allowing proper differentiation for both public and private realtime interactions.

Can I use a single Supabase auth user to support Realtime with RBAC?

Yes, a single Supabase auth user can support Realtime with RBAC by acting as a unified transport layer. Differentiation between user roles and access levels is handled dynamically via app_metadata updated within the JWT.

What is the best way to manage OAuth sign-in flows and token lifecycles in Supabase?

The best way to manage OAuth sign-in flows and token lifecycles is using server-side token generation paired with client-side token management. This approach handles token switching automatically and secures data operations across user sessions.

Why use in-memory token storage instead of localStorage for Supabase client-side caching?

In-memory token storage is used for Supabase client-side caching to reduce exposure risks. By avoiding localStorage, client-side caching minimizes the attack surface while still automatically selecting and caching the appropriate token based on sign-in state.