config/auth.yml and environment variables that control:
- Whether local email/password login is enabled
- Whether an emergency super-admin override is allowed
- How JIT SSO account creation behaves (create vs link-only, allowed domains)
- Which SSO providers appear as buttons on the login page
Create an OIDC / OAuth Client in Your IdP
- Google
- Other OIDC Providers
Create a Google Cloud Project
- Visit console.cloud.google.com and sign in
- Create a new project or select an existing one
Configure OAuth consent screen
Go to APIs & Services > OAuth consent screen and configure your consent screen
Create OAuth credentials
- Go to APIs & Services > Credentials and click Create Credentials > OAuth client ID
- Select Web application as the application type
-
Add an authorized redirect URI:
For local development:
For production:
Configure Sure: OIDC Core Settings
Set the following environment variables in your deployment (e.g..env, docker-compose, or hosting platform):
Restart the application after saving the variables. When OIDC is correctly configured, users can sign in from the login page using the Sign in with OpenID Connect button (label can be customized).
Auth Configuration (config/auth.yml)
Authentication behavior is driven by config/auth.yml, which can be overridden via environment variables.
Structure
Local login flags
When
true, the login page shows the email/password form and “Forgot password” link.
When false, local login is disabled for all users unless the admin override flag is enabled.
Password reset via Sure is also disabled when false.When
true and AUTH_LOCAL_LOGIN_ENABLED=false, super-admin users can still log in with local passwords.
Regular users remain SSO-only. The login form is visible with a note: “Local login is restricted to administrators.”
Successful override logins are logged in the Rails logs.JIT user creation
Controls how new SSO identities are handled:
create_and_link: If the SSO identity is new and the email does not match an existing user, Sure will offer to create a new account (subject to domain checks)link_only: New SSO identities can only be linked to existing users; JIT account creation is disabled. Users without an existing account are sent back to the login page with an explanatory message
Optional comma-separated list of domains (e.g.
example.com,corp.com).- When empty, JIT SSO account creation is allowed for any verified email
- When set, JIT SSO account creation is only allowed if the email domain is in this list
- Applies uniformly to all SSO providers (OIDC, Google, GitHub, etc.) that supply an email
Providers and buttons
Each provider entry inproviders configures an SSO button on the login page:
id: a short identifier used in docs and conditionalsstrategy: the OmniAuth strategy (openid_connect,google_oauth2,github, …)name: the OmniAuth provider name, which determines the/auth/:providerpathlabel: button text shown to usersicon: optional icon name passed to the Sureiconhelper (e.g.key,google,github)
Special behavior:
- Providers with
id: "google"orstrategy: "google_oauth2"render a Google-branded sign-in button - Other providers (e.g. OIDC/Keycloak, GitHub) render a generic styled button with the configured label and icon
Enabling Google sign-in
The Google button is only shown when the Google provider is actually registered by OmniAuth at boot. To enable Google:Verify config
Ensure the Google provider exists in
config/auth.yml under providers: with strategy: "google_oauth2".Configure redirect URI
In your Google Cloud OAuth client configuration, add an authorized redirect URI that matches the host you use in dev.Common local values:
http://localhost:3000/auth/google_oauth2/callbackhttp://127.0.0.1:3000/auth/google_oauth2/callback
name in config/auth.yml, the callback path changes accordingly:http://localhost:3000/auth/<provider_name>/callback
Bootstrapping the first super-admin
The firstsuper_admin must be set via Rails console. Access the console in your container/pod or directly on the server:
/admin/users.
Example Configurations
- Default Hybrid (Local + SSO)
- Pure SSO-Only
- SSO-Only with Emergency Admin Override
- Link-Only JIT + Restricted Domains
This is effectively the default configuration:Behavior:
- Users can sign in with email/password or via any configured SSO providers
- JIT SSO account creation is allowed for all verified email domains
Multiple OIDC Providers
Sure supports configuring multiple OIDC providers simultaneously, allowing users to choose between different identity providers (e.g., Keycloak, Authentik, Okta) on the login page.YAML-based multi-provider configuration
To add multiple OIDC providers inconfig/auth.yml, add additional provider entries with unique names:
Database-Backed Provider Management
For more dynamic provider management, Sure supports storing SSO provider configurations in the database with a web-based admin interface.Enabling database providers
Set the feature flag to load providers from the database instead of YAML:- Providers are loaded from the
sso_providersdatabase table - Changes take effect immediately (no server restart required)
- Providers can be managed through the admin UI at
/admin/sso_providers
- Providers are loaded from
config/auth.yml - Changes require a server restart
Admin UI for SSO providers
Super-admin users can manage SSO providers through the web interface:Seeding providers from YAML to database
To migrate your existing YAML configuration to the database:- Reads providers from
config/auth.yml - Creates or updates database records (idempotent)
- Preserves existing client secrets if not provided in YAML
- Provides detailed output (created/updated/skipped/errors)
Migration workflow
Recommended steps to migrate from YAML to database-backed providers:Rollback to YAML
To switch back to YAML-based configuration:- Remove or set
AUTH_PROVIDERS_SOURCE=yaml - Restart the application
- Providers will be loaded from
config/auth.yml
JIT provisioning settings
Each provider has a Default Role field (defaults tomember) that sets the role for JIT-created users.
Role mapping from IdP groups:
Expand “Role Mapping” in the admin UI to map IdP group names to Sure roles. Enter comma-separated group names for each role:
- Super Admin Groups:
Platform-Admins, IdP-Superusers - Admin Groups:
Team-Leads, Managers - Member Groups:
Everyoneor leave blank
Mapping is case-sensitive and matches exact group claim values from the IdP. When a user belongs to multiple mapped groups, the highest role wins (
super_admin > admin > member). If no groups match, the Default Role is used.Self-Signed Certificate Support
If your identity provider uses self-signed certificates or certificates from an internal CA, configure the following environment variables:| Variable | Description | Default |
|---|---|---|
SSL_CA_FILE | Path to custom CA certificate (PEM format) | Not set |
SSL_VERIFY | Enable/disable SSL verification | true |
SSL_DEBUG | Enable verbose SSL logging | false |
Option 1: Custom CA certificate (recommended)
Mount your CA certificate into the container and setSSL_CA_FILE:
- Be in PEM format (starts with
-----BEGIN CERTIFICATE-----) - Be readable by the application
- Be the CA certificate that signed your server’s SSL certificate
Option 2: Disable SSL verification (NOT recommended for production)
For testing only, you can disable SSL verification:Troubleshooting SSL issues
Enable debug logging to diagnose SSL certificate problems:- Which CA file is being used
- SSL verification mode
- Detailed error messages with resolution hints
| Error | Solution |
|---|---|
self-signed certificate | Set SSL_CA_FILE to your CA certificate |
certificate verify failed | Ensure SSL_CA_FILE points to the correct CA |
certificate has expired | Renew the server’s SSL certificate |
unknown CA | Add the issuing CA to SSL_CA_FILE |
SAML 2.0 Support
Sure supports SAML 2.0 via database-backed providers. Select “SAML 2.0” as the strategy when adding a provider at/admin/sso_providers.
Configure with either:
- IdP Metadata URL (recommended) - auto-fetches configuration
- Manual config - IdP SSO URL + certificate
- ACS URL:
https://yourdomain.com/auth/<provider_name>/callback - Entity ID:
https://yourdomain.com(yourAPP_URL) - Name ID: Email Address
User Administration
Super-admins can manage user roles at/admin/users.
Roles:
member(standard)admin(family admin)super_admin(platform admin)
Super-admins cannot change their own role.
Audit Logging
SSO events are logged tosso_audit_logs: login, login_failed, logout, logout_idp (federated logout), link, unlink, jit_account_created.
Query via console:
User SSO Identity Management
Users manage linked SSO identities at Settings > Security.Troubleshooting
Provider not appearing on login page
Provider not appearing on login page
YAML mode: Check that required environment variables are set (e.g.,
OIDC_ISSUER, OIDC_CLIENT_ID, OIDC_CLIENT_SECRET)DB mode: Verify provider is enabled in /admin/sso_providersCheck application logs for provider loading messages and verify AUTH_PROVIDERS_SOURCE is set correctly.Discovery endpoint validation fails
Discovery endpoint validation fails
When adding an OIDC provider, Sure validates the
.well-known/openid-configuration endpoint:- Ensure the issuer URL is correct and accessible
- Check firewall rules allow outbound HTTPS to the issuer
- Verify the issuer returns valid JSON with an
issuerfield - For self-signed certificates, configure SSL verification (see above)
Rate limiting errors (429)
Rate limiting errors (429)
Admin endpoints are rate-limited to 10 requests per minute per IP:
- Wait 60 seconds before retrying
- If legitimate traffic is being blocked, adjust limits in
config/initializers/rack_attack.rb
Callback URL mismatch
Callback URL mismatch
Each provider requires a callback URL configured in your identity provider:
- Format:
https://yourdomain.com/auth/<provider_name>/callback - Example: For a provider with
name: "keycloak", usehttps://yourdomain.com/auth/keycloak/callback - The callback URL is shown in the admin UI when editing a provider (with copy button)
Security Considerations
Encryption
- Client secrets are encrypted at rest using Rails 7.2 ActiveRecord Encryption
- Encryption keys are derived from
SECRET_KEY_BASEby default - For additional security, set custom encryption keys (see
.envforACTIVE_RECORD_ENCRYPTION_*variables)
Issuer validation
- OIDC identities store the issuer claim from the ID token
- On subsequent logins, Sure verifies the issuer matches the configured provider
- This prevents issuer impersonation attacks
Admin access
- SSO provider management requires
super_adminrole - Regular
adminusers (family admins) cannot access/admin/sso_providers - All provider changes are logged with user ID
Rate limiting
- Admin endpoints: 10 requests/minute per IP
- OAuth token endpoint: 10 requests/minute per IP
- Failed login attempts should be monitored separately