Supported Providers
StellarStack supports three OAuth providers:- Google - Best for general users, widely adopted
- GitHub - Ideal for developer-focused communities
- Discord - Perfect for gaming communities
How OAuth Works
When a user signs in with OAuth:- They click “Sign in with Google/GitHub/Discord”
- They’re redirected to the provider’s authorization page
- After granting permission, they’re redirected back to StellarStack
- StellarStack creates an account or links to an existing account based on email
- The user is logged in automatically
[email protected] and an account already exists with that email, the accounts will be linked automatically.Google OAuth Setup
Create a Google Cloud Project
Enable Google+ API
Configure OAuth Consent Screen
- Select “External” for user type (unless you have a Google Workspace)
- Enter your app name (e.g., “StellarStack Panel”)
- Add your support email
- Add your domain to “Authorized domains”
- Add your privacy policy and terms of service URLs (if applicable)
Create OAuth Credentials
- Application type: “Web application”
- Name: “StellarStack Web Client”
- Authorized JavaScript origins: Add your frontend URL
- Authorized redirect URIs: Add your API callback URL
Copy Client ID and Secret
Google OAuth URLs
- Authorized JavaScript origins: Where your frontend is hosted
- Authorized redirect URIs:
{API_URL}/api/auth/callback/google
GitHub OAuth Setup
Register OAuth Application
Configure Application Details
- Application name: StellarStack Panel
- Homepage URL: Your panel URL
- Authorization callback URL: Your API callback URL
- Application description: (Optional) “Game server management panel”
Generate Client Secret
GitHub OAuth Scopes
StellarStack requests these scopes:user:email- Access to email addressesread:user- Read user profile information
Discord OAuth Setup
Create Discord Application
Configure OAuth2 Settings
- Click “Add Redirect” under “Redirects”
- Enter:
https://api.yourdomain.com/api/auth/callback/discord - Click “Save Changes”
Copy Client ID and Secret
- Copy the “Client ID”
- Click “Reset Secret” to generate a new client secret
- Copy the client secret (it will only be shown once)
Discord OAuth Scopes
StellarStack requests:identify- Access to username, avatar, and discriminatoremail- Access to email address
Environment Variables Reference
All OAuth configuration happens through environment variables in your API service:Testing OAuth Configuration
Verify Provider Appears
Test Sign In Flow
- You’re redirected to the provider’s authorization page
- The app name and permissions match what you configured
- After authorizing, you’re redirected back to StellarStack
- Your account is created or you’re logged in
Check Account Linking
- Go to account settings
- Check the “Connected Accounts” section
- Your OAuth provider should be listed
Account Linking
Users can link multiple authentication methods to their account:Linking Additional Providers
- Log in with any method (email/password or OAuth)
- Go to account settings
- Click “Connect” next to the provider you want to link
- Authorize the connection
Unlinking Providers
To remove an OAuth connection:- Go to account settings
- Find the connected provider
- Click “Disconnect”
Security Considerations
OAuth vs. Email/Password
OAuth Benefits:- Leverages provider’s security infrastructure
- No password to remember or store
- Automatically gets provider’s 2FA protection
- Faster sign-in experience
- Dependency on third-party service
- Account compromise if provider account is compromised
- Less control over authentication flow
Protecting Client Secrets
- Never commit secrets to version control - Use
.envfiles and.gitignore - Rotate secrets periodically - Generate new client secrets every 6-12 months
- Restrict access - Only administrators should have access to OAuth credentials
- Use environment-specific credentials - Different secrets for dev, staging, and production
Redirect URI Validation
OAuth providers validate redirect URIs to prevent authorization code interception:- Use exact matches (no wildcards)
- Always use HTTPS in production (required by most providers)
- Don’t use localhost or IP addresses in production configurations
- Keep your authorized redirect list minimal
Troubleshooting
OAuth button doesn't appear
OAuth button doesn't appear
Redirect URI mismatch error
Redirect URI mismatch error
- Check your
API_URLenvironment variable - Verify the redirect URI in the provider console is exactly:
{API_URL}/api/auth/callback/{provider} - Ensure no trailing slashes
- Confirm you’re using the correct protocol (http vs https)
Email already in use error
Email already in use error
- Log in with the existing authentication method
- Go to account settings and link the OAuth provider
- Then you can use either method to log in
Invalid client error from provider
Invalid client error from provider
- Double-check you copied the full client ID and secret
- Verify no extra spaces or characters were copied
- Regenerate the client secret if you’re unsure
- Update your
.envfile and restart the API
Access denied error
Access denied error
- Ensure OAuth consent screen is published (not in testing mode)
- Verify requested scopes are approved
- For Google, check that Google+ API is enabled
- Try again and click “Allow” when prompted
User profile data not syncing
User profile data not syncing
- Verify you’re requesting the correct scopes
- For GitHub, ensure
user:emailandread:userare requested - For Discord, ensure
identifyandemailare requested - Have the user disconnect and reconnect the provider
Best Practices
Enable Multiple Providers
Enable Multiple Providers
Keep Email/Password Available
Keep Email/Password Available
Sync User Profiles
Sync User Profiles
Monitor OAuth Usage
Monitor OAuth Usage
Document Provider Requirements
Document Provider Requirements
Test Provider Changes
Test Provider Changes
Advanced Configuration
Custom OAuth Scopes
If you need additional user data, you can request more scopes by modifying the auth configuration inapps/api/src/lib/auth.ts. However, be mindful that:
- Users may decline authorization if you request too many permissions
- More scopes require more justification in OAuth consent screens
- Some scopes require provider verification or approval
OAuth Provider Restrictions
You can restrict OAuth to specific domains or organizations: Google: Use Google Workspace and configure allowed domains in the OAuth consent screen. GitHub: Check user’s organization membership after authentication:Automatic Account Provisioning
You can customize what happens when users first authenticate with OAuth:- Set default roles based on provider
- Auto-grant permissions based on OAuth data
- Assign users to specific servers or groups
- Send welcome emails or notifications
Migration Guide
If you’re migrating from another panel and want to preserve user accounts:- Export user emails from your old system
- Create StellarStack accounts with those emails
- Send password reset emails to all users
- Users can set their password or link OAuth providers