How SSO login works
When a user initiates an SSO login, MonoRelay redirects them to the OAuth provider’s authorization page. After they grant access, the provider sends an authorization code back to MonoRelay’s callback endpoint (/api/auth/sso/callback). MonoRelay exchanges this code for the user’s profile, finds or creates a matching local account, and issues a JWT token. From that point on, the user authenticates with their JWT exactly like any other user.
SSO users receive a standard MonoRelay JWT after login. They use it identically to local account tokens — pass it as
Authorization: Bearer <token> on every API request.Setup
1
Create an OAuth app with your provider
Register a new OAuth application with GitHub or Google and set the callback URL to:GitHub: Go to github.com/settings/developers → “OAuth Apps” → “New OAuth App”. Set the “Authorization callback URL” to the value above.Google: Go to the Google Cloud Console → “APIs & Services” → “Credentials” → “Create credentials” → “OAuth client ID”. Add the callback URL to the list of authorized redirect URIs.After creating the app, copy the client ID and client secret — you will need them in the next step.
2
Add SSO configuration to config.yml
Add an Google:MonoRelay picks up configuration changes without a restart when hot-reload is active.
sso section to your config.yml. The example below shows GitHub; for Google, replace the github_* fields with google_* fields.GitHub:3
Optionally promote SSO users to admin
Add usernames to Users already in the database will be promoted to admin on their next SSO login if their username appears in this list.
admin_usernames to automatically grant the admin role to those users when they first log in via SSO. The username is the login name from the OAuth provider (for example, your GitHub username).4
Optionally disable local password login
Set
sso_only: true to prevent anyone from logging in with a local username and password. Only SSO login will be accepted.