Overview
Uxie uses NextAuth.js for authentication, integrated with tRPC procedures to provide secure, type-safe API access.Authentication Provider
Currently, Uxie supports authentication via:Google OAuth
Sign in with your Google account for secure, hassle-free authentication
Configuration
The authentication is configured in/src/server/auth.ts:
Session Management
JWT Strategy
Uxie uses JWT (JSON Web Tokens) for session management:- Sessions are stored as encrypted tokens
- No database queries needed to validate sessions
- Automatically refreshed on each request
Session Data
The session includes enriched user data from the database:Protected Procedures
Using Protected Procedures
Most API endpoints in Uxie require authentication. These useprotectedProcedure instead of publicProcedure:
Authentication Middleware
TheprotectedProcedure uses middleware that enforces authentication:
Public Procedures
Some endpoints are public and don’t require authentication:Getting the Session
On the Client
Use NextAuth’suseSession hook:
On the Server
In API routes orgetServerSideProps:
Authorization Patterns
Resource Ownership
Check if the user owns a resource:Collaboration Access
Check if the user is an owner or collaborator:Role-Based Access
Check specific collaborator roles:Sign In/Sign Out
Sign In
Sign Out
Error Handling
Authentication errors return theUNAUTHORIZED error code:
