Complete SSO Workflow & Debugging Guide
Step-by-step workflow for implementing, debugging, and maintaining RegardingWork Hub SSO
Complete SSO Authentication Flow
โ Successful SSO Flow
- User Action: Clicks "Login with RegardingWork Hub" on your service
- Redirect: Browser goes to
hub.regardingwork.com/api/auth/sso/authorize?redirect_uri=your-callback
- Domain Check: Hub validates your domain is in the allowed SSO domains list
- Authentication Check: Hub checks if user is logged in
- Token Generation: Hub generates JWT access token for authenticated user
- Callback Redirect: Hub redirects to your callback URL with token parameters
- Token Validation: Your service validates the token with Hub's validate endpoint
- User Login: Your service logs in the user based on validated token
๐ Key URLs
SSO Authorize:hub.regardingwork.com/api/auth/sso/authorize
Token Validation:
hub.regardingwork.com/api/auth/validate
Your Callback:
your-domain.com/auth/callback
Common SSO Errors & How to Debug Them
โ Error: "Invalid redirect_uri domain: your-domain.com"
What this means: Hub doesn't recognize your domain as authorized for SSO
Why it happens: Your domain isn't in the Hub's SSO domains database
- Ask Hub admin to add your domain via /admin/sso-domains
- Or add it yourself if you have admin access
- Make sure to use exact domain match (no https://, no trailing /)
โ Error: "SSO authorization failed"
What this means: Domain was accepted but something crashed during authorization
Common causes: Missing imports, user not logged into Hub, token generation failure
- Check if logged in: Make sure you're logged into hub.regardingwork.com first
- Check production logs: Go to Replit Deployments โ Logs tab for exact error
- Common fix: Add missing
from auth_service import AuthService
imports - Verify database: Check if production has database connection issues
โ ๏ธ Result: 404 on Callback URL
What this means: SSO worked perfectly! Your service just needs to build the callback handler
Why it happens: Hub successfully generated token and redirected, but your service doesn't have /auth/callback
endpoint yet
โน๏ธ Error: "Please log in to hub.regardingwork.com first"
What this means: User isn't authenticated to Hub yet
This is good UX! Clear message telling user exactly what to do
- Go to hub.regardingwork.com/login
- Login with Hub credentials
- Return and try the SSO URL again
Step-by-Step Debugging Process
๐ When SSO Isn't Working, Follow This Process:
Phase 1: Test the SSO URL
- Test basic SSO URL:
hub.regardingwork.com/api/auth/sso/authorize?redirect_uri=https://your-domain.com/auth/callback
- Check error message type:
- "Invalid domain" โ Domain not whitelisted
- "SSO authorization failed" โ Check logs
- "Please log in" โ User not authenticated
- 404 on callback โ SSO working, need callback
Phase 2: Check Environment
- Verify deployment status:
Make sure latest code is deployed to production - Check database domains:
Visit /admin/sso-domains to see allowed domains - Review production logs:
Replit Deployments โ Logs tab for exact errors
Pro Tip: Error Message Analysis
Pay attention to how error messages change as you fix issues:
"Invalid domain"
โ"SSO authorization failed"
= Domain fix worked, now check authentication"SSO authorization failed"
โ404 on callback
= Authentication fix worked, now build callback
Production vs Development Environment Issues
โ Development (localhost:5000)
- โ Database-driven SSO domains
- โ All RegardingWork domains working
- โ Enhanced logging active
- โ Latest code changes
localhost:5000/api/auth/sso/authorize?redirect_uri=https://premium.regardingwork.com/auth/callback
โ Production (hub.regardingwork.com)
Common Issue: Production environment missing recent code updates
- โ Using old hardcoded domain system
- โ Missing database domain queries
- โ Missing AuthService imports
- โ Outdated error handling
Deployment Checklist
- Code: Deploy latest SSO fixes to production
- Database: Add missing domains to production database
- Test: Verify SSO URLs work on production
- Monitor: Check production logs for any new errors
SSO Domain Management & Admin Tools
๐ ๏ธ Administrative Actions
Add New SSO Domain
Go to SSO Domain Management to add new domains
Required for each new RegardingWork service that needs SSO authenticationView Current Domains
Current production domains should include:
- premium.regardingwork.com
- game.regardingwork.com
- display.regardingwork.com
- ce.regardingwork.com
- family.regardingwork.com
- desk.regardingwork.com
- teams.regardingwork.com
Diagnostic Tools
Use Diagnostics Dashboard to:
- View production vs development database status
- Test SSO domain validation
- Check authentication service health
- Add missing domains with one click
Quick Admin Links
Service Integration Template
๐ For New RegardingWork Services
Use this template when adding SSO to a new service:
<!-- Replace login form with SSO button -->
<a href="https://hub.regardingwork.com/api/auth/sso/authorize?redirect_uri=https://YOUR-DOMAIN.com/auth/callback&service=YOUR-SERVICE-NAME"
class="btn btn-primary btn-lg">
<i data-feather="shield" class="me-2"></i>
Login with RegardingWork Hub
</a>
# Example Python/Flask callback handler
@app.route('/auth/callback')
def auth_callback():
token = request.args.get('token')
user_id = request.args.get('user_id')
username = request.args.get('username')
if not token:
return redirect('/login?error=no_token')
# Validate token with Hub
response = requests.get(
'https://hub.regardingwork.com/api/auth/validate',
headers={'Authorization': f'Bearer {token}'}
)
if response.ok:
# Success! Log user in
session['hub_token'] = token
session['user_id'] = user_id
session['username'] = username
return redirect('/dashboard')
else:
return redirect('/login?error=invalid_token')
- Add Domain: Go to /admin/sso-domains
- Enter Domain: your-service.regardingwork.com (no protocol, no trailing slash)
- Add Description: "Your Service Name - Description"
- Test SSO URL: Try the complete flow with your callback URL
- Monitor: Check both Hub and your service logs for any issues
Testing & Validation
๐งช Test Your SSO Integration
- Test the SSO URL manually:
Visit:hub.regardingwork.com/api/auth/sso/authorize?redirect_uri=https://YOUR-DOMAIN.com/auth/callback
- Expected success flow:
- Domain accepted โ
- User redirected to login if needed โ
- Token generated and callback executed โ
- Test error scenarios:
- User not logged into Hub
- Invalid callback URL
- Token validation failure
โ Success Indicators
When SSO is Working Correctly:
- No "Invalid domain" errors
- Users get redirected to your callback with token parameters
- Token validation returns user data
- Users are logged into your service automatically
Remember:
- 404 on your callback = SSO working, build your handler
- Always validate tokens received from SSO
- Handle authentication gracefully
- Provide clear error messages to users