OAuth Configuration
Conducky supports social login with Google and GitHub OAuth, allowing users to sign in with their existing accounts. This guide walks System Admins through setting up and configuring social login.
๐ Overviewโ
Social login provides several benefits:
- Faster registration: Users can sign up instantly with existing accounts
- Improved security: No need to manage additional passwords
- Better user experience: One-click login for returning users
- Account linking: Users can link multiple social accounts to one Conducky account
๐ Prerequisitesโ
Before configuring social login, you'll need:
- Google Cloud Console access (for Google OAuth)
- GitHub account with Developer Settings access (for GitHub OAuth)
- SSL certificate (HTTPS) for production deployments
- System Admin access to your Conducky instance
๐ง Setting Up Google OAuthโ
Step 1: Create Google Cloud Projectโ
- Go to Google Cloud Console
- Create a new project or select an existing one
- In the project dashboard, ensure you're in the correct project
Step 2: Enable Google Identity Services APIโ
- Navigate to APIs & Services โ Library
- Search for "Google Identity Services API"
- Click on "Google Identity Services API" and click "Enable"
- Alternatively, you can also enable "Google+ API" if available, but Google Identity Services is the modern approach
Step 3: Create OAuth 2.0 Credentialsโ
- Go to APIs & Services โ Credentials
- Click "Create Credentials" โ "OAuth 2.0 Client ID"
- If prompted, configure the OAuth consent screen first:
- User Type: External (for most cases)
- App Information:
- App name: "Conducky" (or your installation name)
- User support email: Your admin email
- Developer contact information: Your admin email
- Scopes: Add the following scopes:
../auth/userinfo.email
(to access user's email address)../auth/userinfo.profile
(to access user's basic profile info)
- Test users: Add your test email addresses
- Return to create OAuth 2.0 Client ID:
- Application type: Web application
- Name: "Conducky OAuth Client"
- Authorized JavaScript origins:
- Local development:
http://localhost:3001
- Production:
https://yourdomain.com
- Local development:
- Authorized redirect URIs:
- Local development:
http://localhost:4000/api/auth/google/callback
- Production:
https://yourdomain.com/api/auth/google/callback
- Local development:
- Click "Create"
- Copy the Client ID and Client Secret - you'll need these for configuration
Step 4: Configure OAuth Consent Screen (Production)โ
For production use:
- Go to APIs & Services โ OAuth consent screen
- Fill in all required fields
- Add your domain to Authorized domains
- Submit for verification if needed (required for external users)
๐ Setting Up GitHub OAuthโ
Step 1: Create GitHub OAuth Appโ
- Go to GitHub Settings โ Developer settings โ OAuth Apps
- Click "New OAuth App"
- Fill in the application details:
- Application name: "Conducky" (or your installation name)
- Homepage URL:
- Local:
http://localhost:3001
- Production:
https://yourdomain.com
- Local:
- Application description: "Code of conduct incident management system"
- Authorization callback URL:
- Local:
http://localhost:4000/api/auth/github/callback
- Production:
https://yourdomain.com/api/auth/github/callback
- Local:
- Click "Register application"
- Copy the Client ID and Client Secret - you'll need these for configuration
โ๏ธ Conducky Configurationโ
OAuth Settings Locationโ
OAuth configuration for Google and GitHub is managed directly in the Conducky database through the System Settings UI.
Configuring OAuth Providersโ
- Log in as a System Admin
- Navigate to System Admin โ System Settings in the sidebar
- Go to the "OAuth Providers" section
Here you can:
- Add or update the Client ID and Client Secret for Google and GitHub
- Set the Authorized Redirect URIs (these must match your OAuth app configuration)
- Enable or disable each provider as needed
Note: Changes take effect immediately after saving.
Production Configurationโ
For production deployments:
- Enter your production OAuth credentials and redirect URIs in the System Settings UI
- Ensure your OAuth app configuration in Google and GitHub matches the redirect URIs shown in the settings screen
- No changes to
.env
ordocker-compose.yml
are required for OAuth
๐ Security Considerationsโ
Credential Protectionโ
- Only System Admins can view or modify OAuth credentials
- Credentials are encrypted at rest in the database
- Use strong, unique client secrets from providers
Redirect URI Securityโ
- Always use HTTPS in production
- Verify redirect URIs match exactly between provider and Conducky
- Regularly audit and update OAuth app configurations
Access Scope Limitationsโ
- Request only necessary scopes (email, profile)
- Review and minimize data access permissions
- Document what data is accessed and why
๐งช Testing Social Loginโ
Local Testing Setupโ
- Configure OAuth apps with local callback URLs (as shown above)
- Test the setup by following the testing scenarios below
Testing Scenariosโ
Test Case 1: New User Registration via Googleโ
- Navigate to
http://localhost:3001/login
- Click the "Google" button
- Complete Google OAuth flow with a Google account NOT already in Conducky
- Expected Results:
- User is redirected to
/dashboard
after successful auth - New user account is created in database
- User's name and email are populated from Google profile
- No password hash is set (passwordHash should be null)
- SocialAccount record is created with Google provider data
- User is redirected to
Test Case 2: New User Registration via GitHubโ
- Navigate to
http://localhost:3001/login
- Click the "GitHub" button
- Complete GitHub OAuth flow with a GitHub account NOT already in Conducky
- Expected Results:
- User is redirected to
/dashboard
after successful auth - New user account is created in database
- User's name and email are populated from GitHub profile
- No password hash is set (passwordHash should be null)
- SocialAccount record is created with GitHub provider data
- User is redirected to
Test Case 3: Existing User Account Linkingโ
- Create a user account with email
test@example.com
(via regular registration) - Navigate to
/login
- Click "Google" button and authenticate with Google account using
test@example.com
- Expected Results:
- User is logged in to existing account
- SocialAccount record is created linking Google account to existing user
- User retains their existing data and event roles
Test Case 4: OAuth Error Handlingโ
- Configure invalid OAuth credentials in System Settings
- Navigate to
/login
- Click "Google" or "GitHub" button
- Expected Results:
- User is redirected to
/login?error=oauth_failed
- Error message is displayed: "Social login failed. Please try again or use email/password."
- User is redirected to
Database Verificationโ
After testing, verify the database state:
Check Users Table:
SELECT id, email, name, "passwordHash" FROM "User" WHERE email = 'test@example.com';
passwordHash
should be null for OAuth-only users
Check SocialAccounts Table:
SELECT * FROM "SocialAccount" WHERE "userId" = 'user-id';
- Should contain provider data and access tokens
๐จ Troubleshootingโ
Common Issuesโ
Users Cannot Log In via Social Providers
- Double-check OAuth credentials and redirect URIs in System Settings
- Ensure OAuth app configuration matches exactly (including protocol and domain)
- Review error messages for hints about misconfiguration
Redirect URI Mismatch
- Verify redirect URIs in provider settings match Conducky configuration
- Check for trailing slashes or protocol mismatches
- Ensure development vs production URLs are correctly configured
OAuth App Not Approved
- For Google: Submit OAuth app for verification if needed
- For GitHub: Ensure OAuth app is properly registered
- Check provider-specific approval requirements
Missing User Information
- Verify requested scopes include email and profile
- Check provider permissions and consent screen
- Review user's privacy settings on provider platform
Error Messagesโ
"OAuth configuration not found"
- Solution: Configure OAuth providers in System Settings
- Check: Ensure Client ID and Secret are properly saved
"Invalid redirect URI"
- Solution: Update redirect URIs in provider settings
- Check: Verify exact match including protocol and domain
"OAuth provider disabled"
- Solution: Enable the provider in System Settings
- Check: Verify provider toggle is set to enabled
Debugging Stepsโ
- Check System Settings: Verify OAuth configuration is complete
- Review Provider Settings: Ensure OAuth apps are properly configured
- Test Credentials: Use provider's testing tools to verify credentials
- Check Logs: Review application logs for detailed error messages
- Verify Network: Ensure proper connectivity to provider APIs
๐ Best Practicesโ
Configuration Managementโ
- Document settings: Keep records of OAuth app configurations
- Regular updates: Review and update OAuth credentials periodically
- Testing procedures: Establish regular testing of social login flows
- Backup configurations: Maintain backups of OAuth app settings
User Experienceโ
- Clear instructions: Provide clear guidance for social login
- Fallback options: Always provide email/password as alternative
- Error handling: Implement graceful error handling and user feedback
- Account linking: Allow users to link multiple social accounts
Security Maintenanceโ
- Regular audits: Review OAuth app permissions and access
- Credential rotation: Periodically rotate client secrets
- Monitoring: Monitor for unusual OAuth-related activity
- Updates: Stay current with provider security recommendations