Overview
suSHi supports OAuth 2.0 authentication with Google and GitHub, allowing you to sign in using your existing accounts without creating separate credentials. Benefits:- No password to remember
- Leverages battle-tested authentication providers
- Easy account linking and recovery
- Seamless single sign-on experience
Supported Providers
Google OAuth
Sign in with your Google account (@gmail.com or Google Workspace)
GitHub OAuth
Sign in with your GitHub account (personal or organization)
How OAuth Works
suSHi implements the OAuth 2.0 authorization code flow:suSHi never sees your OAuth provider password. Authentication happens directly with Google or GitHub.
Google OAuth
Authorization Flow
When you sign in with Google:- Redirect to Google: You’re sent to Google’s OAuth authorization page
- Permission Request: Google asks you to authorize suSHi
- Callback: Google redirects back with authorization code
- Token Exchange: suSHi exchanges code for access token
- Fetch Profile: suSHi retrieves your email and name
- Account Creation: Your account is created or updated
Requested Scopes
suSHi requests the following permissions:- userinfo.email: Required to identify your account
- userinfo.profile: Used to display your name in the dashboard
suSHi only requests read-only access to basic profile information. No access to Gmail, Drive, or other Google services.
User Information Retrieved
From Google’s API:- Create your suSHi account (email as username)
- Display your name in the dashboard
- Associate machines with your account
Authorization URL
Generated URL format:URL Parameters Explained
URL Parameters Explained
- client_id: Your Google OAuth app identifier
- redirect_uri: Where to send users after authorization
- response_type:
codefor authorization code flow - scope: Requested permissions (space-separated)
- state: Random string to prevent CSRF attacks
GitHub OAuth
Authorization Flow
When you sign in with GitHub:- Redirect to GitHub: You’re sent to GitHub’s OAuth authorization page
- Permission Request: GitHub asks you to authorize suSHi
- Callback: GitHub redirects back with authorization code
- Token Exchange: suSHi exchanges code for access token
- Fetch Profile: suSHi retrieves your email and username
- Email Verification: If email not public, fetches from emails API
- Account Creation: Your account is created or updated
Requested Scopes
suSHi requests:- read:user: Grants read-only access to profile information
- read:email: Needed to access your verified email addresses
- GitHub doesn’t include email in basic profile by default
- suSHi needs your email to create your account
If your email is public on GitHub, we fetch it from your profile. Otherwise, we use the verified primary email from your account settings.
User Information Retrieved
From GitHub’s API:- Email from main profile (if public)
- Primary verified email from emails API
- First verified email found
Authorization URL
Generated URL format:Security Features
- State Parameter
- Token Exchange
- HTTPS Only
- JWT Tokens
The
state parameter prevents CSRF attacks:- suSHi generates a random state string
- Stores it in your session
- Sends it to OAuth provider
- Validates it on callback
Setting Up OAuth (For Self-Hosting)
If you’re running your own suSHi instance, you’ll need to configure OAuth:Google OAuth Setup
Create Project
Go to Google Cloud Console
Configure Client
- Application type: Web application
- Authorized redirect URIs:
https://your-domain.com/auth/google/callback
GitHub OAuth Setup
Developer Settings
Configure App
- Application name: suSHi
- Homepage URL:
https://your-domain.com - Callback URL:
https://your-domain.com/auth/github/callback
The
state parameter should be a cryptographically random string. Generate it securely and keep it secret.Using OAuth in Your Application
Initiating OAuth Flow
To start authentication:Handling Callback
After user authorizes:Troubleshooting
Redirect URI mismatch
Redirect URI mismatch
Error:
redirect_uri_mismatch or The redirect URI in the request does not matchCause: The redirect URI in your request doesn’t match the one configured in OAuth app settings.Solutions:- Verify exact match (including protocol, domain, path)
- Check for trailing slashes:
/callbackvs/callback/ - Ensure HTTPS in production
- Update OAuth app settings to match your configuration
Invalid state parameter
Invalid state parameter
Error:
Invalid state parameter or CSRF protection failedCause: State parameter doesn’t match between request and callbackSolutions:- Ensure state is stored in session/cookie
- Check for session expiry
- Verify state generation and validation logic
- Clear browser cookies and retry
Email not found (GitHub)
Email not found (GitHub)
Error: No verified email found on GitHub accountCause: GitHub account has no verified email addressesSolutions:
- Go to GitHub Email Settings
- Add and verify an email address
- Make email public or ensure it’s verified
- Retry authentication
Token exchange failed
Token exchange failed
Error: Failed to exchange code for tokenCause: Authorization code expired or invalid credentialsSolutions:
- Code expires quickly - complete flow faster
- Verify client ID and secret are correct
- Check OAuth app is not suspended
- Ensure server time is accurate (for token validation)
Best Practices
Use Environment Variables
Never hardcode OAuth credentials. Use environment variables or secret management.
Rotate Secrets Regularly
Periodically regenerate OAuth client secrets for security.
Monitor OAuth Usage
Track authentication failures and suspicious patterns in logs.
Implement Rate Limiting
Prevent brute force attacks on OAuth endpoints with rate limiting.
Next Steps
Security
Learn about security measures in suSHi
Machine Management
Start adding your SSH machines