Supported Providers
GitHub
OAuth 2.0 with scope management for profile linking
Apple
Sign in with Apple using OpenID Connect
OAuth 2.0 for professional profiles
X (Twitter)
OAuth 2.0 with tweet and media permissions
YouTube
OAuth 2.0 for video content creators
Authentication Flow
Profile creation or login
- New user: Individual profile created automatically
- Existing user: Logged into existing account
Session Management
JWT Tokens
Aya uses JSON Web Tokens (JWT) for stateless session management: Token Structure:- Signed with HMAC-SHA256 using server secret
- Default TTL: 8760 hours (365 days)
- Stored in HTTP-only secure cookies
- Cross-domain support for
*.aya.is
Session Cookies
Cookie Configuration:- Name:
aya_session(configurable) - Domain:
.aya.is(configurable for custom domains) - Secure:
truein production (HTTPS only) - HttpOnly:
true(JavaScript cannot access) - SameSite: Configured for CORS support
CORS Configuration
Cross-Origin Resource Sharing (CORS) is configured to support: Allowed Origins (default):https://aya.ishttps://www.aya.ishttp://localhost:3000(development)http://localhost:5173(development)http://localhost:4173(development)
AcceptAuthorizationContent-TypeOriginX-Requested-WithTraceparent,Tracestate(distributed tracing)
GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
CORS settings are configurable via environment variables for custom deployments.
Provider-Specific Details
GitHub Authentication
OAuth Scopes:Initial Login Scope
Initial Login Scope
- Read basic profile information
- Access user email addresses
- Create user account and individual profile
Profile Link Scope
Profile Link Scope
- Link GitHub profile to Aya profile
- Sync public repositories
- Display live repository stats
Organization Scope
Organization Scope
- Read organization memberships
- Link organization accounts
- Sync organization repositories
- User authorizes with GitHub
- System queries GitHub API for user + organizations
- User selects which account to link (personal or org)
- Profile link created with selected account
Apple Authentication
Configuration Requirements:- Client ID (Service ID from Apple Developer)
- Team ID
- Key ID
- Private Key (P8 file from Apple)
- Sign in with Apple button styling
- Native iOS app support (future)
- Email relay privacy protection
Apple provides email relay addresses to protect user privacy. These are treated as verified emails.
LinkedIn Authentication
OAuth Scopes:Login Scope
Login Scope
Profile Link Scope
Profile Link Scope
- Linking LinkedIn profiles
- Reading organization pages
- Selecting personal or organization accounts
- User authorizes
- System fetches personal profile + managed organization pages
- User selects account to link
- Profile link created
X (Twitter) Authentication
OAuth Scopes:Login Scope
Login Scope
Profile Link Scope
Profile Link Scope
- Reading tweets
- Posting tweets (future feature)
- Uploading media
- Offline access via refresh tokens
YouTube Authentication
OAuth Scope:- Link YouTube channel to profile
- Display live stream status
- Sync channel information
- Show subscriber counts
User Account Creation
New User Flow
Create user record
New user created with:
- Unique user ID
- Email (verified from provider)
- Name from provider
- User kind (“user” or “admin”)
Create individual profile
Automatic profile creation with:
- Generated slug (from name or email)
- Profile picture from provider avatar
- Default locale from browser/system
Existing User Flow
Session Lifecycle
Active Sessions
Sessions include:- Unique session ID (ULID)
- User ID
- Created timestamp
- Expiry timestamp (365 days default)
- User preferences (locale, theme, etc.)
Session Preferences
Stored per-session:- UI locale preference
- Theme (light/dark/system)
- Feature flags
- Last visited pages
Session Invalidation
Automatic:- Token expires after TTL (365 days default)
- Cookie expires client-side
- User clicks “Logout”
- Session deleted from database
- Cookie cleared
Security Features
PKCE for OAuth
Aya uses PKCE (Proof Key for Code Exchange) for OAuth flows:- Code challenge generated client-side
- Code verifier stored securely
- Prevents authorization code interception
- Required for public clients
State Parameter
OAuth state includes:- Random state string (CSRF protection)
- Profile context (for profile linking)
- Redirect URI
- Expiry timestamp
Protection Against Attacks
CSRF Protection
OAuth state parameter prevents cross-site request forgery
Token Signing
HMAC-SHA256 signature prevents token tampering
Secure Cookies
HttpOnly + Secure flags prevent XSS attacks
PKCE
Code challenge prevents authorization code interception
API Authentication
For API requests, include JWT in header:Logout Flow
Troubleshooting
'Unauthorized' errors after login
'Unauthorized' errors after login
OAuth callback fails
OAuth callback fails
- Verify provider client ID and secret
- Check redirect URI matches provider config exactly
- Ensure state parameter hasn’t expired (5 min default)
- Confirm provider account has email verified
Session expires too quickly
Session expires too quickly
- Check
token_ttlconfiguration - Verify server time is synchronized (NTP)
- Review JWT expiry timestamp in token
Configuration Reference
Environment Variables:Next Steps
Profiles
Set up your profile after authentication
Organizations
Link organization accounts via OAuth
Telegram Bot
Link Telegram account to your profile
Mailbox
Access authenticated messaging