OIDC Provider Configuration#
Sure's OpenID Connect (OIDC) provider configuration covers how OIDC issuers are declared, how client credentials are resolved, and how SSL/TLS is handled for discovery and token exchange. It is distinct from the SSO authentication flow (session handling, JIT provisioning, role mapping) — this article covers the wiring layer that makes a provider available to OmniAuth.
Configuration Sources#
OIDC providers can be configured in two ways, controlled by the db_sso_providers Flipper feature flag:
- YAML —
config/auth.yml, loaded via Railsconfig_for(:auth) - Database —
SsoProviderrecords, loaded when the Flipper flag is on
ProviderLoader.load_providers abstracts the source, caches the result for 5 minutes, and falls back to YAML if the database is unavailable. Call ProviderLoader.clear_cache after updating providers in the admin UI.
Required Fields#
For strategy openid_connect, all four of the following must be present or the provider is silently skipped during OmniAuth initialization :
| Field | Default env var | Description |
|---|---|---|
issuer | OIDC_ISSUER | Base URL of the IdP (no trailing path) |
client_id | OIDC_CLIENT_ID | OAuth2 client identifier |
client_secret | OIDC_CLIENT_SECRET | OAuth2 client secret |
redirect_uri | OIDC_REDIRECT_URI | Callback URL registered with the IdP |
The config file reads these from environment variables by default . For additional providers beyond the default, use the naming pattern OIDC_<UPPERCASE_NAME>_* (e.g., OIDC_KEYCLOAK_ISSUER) documented in the YAML comments .
ProviderOptionsBuilder#
Oidc::ProviderOptionsBuilder.call(cfg) is the single place that assembles the OmniAuth option hash passed to :openid_connect. Key behaviors:
- Discovery: always
true— the builder assumes the IdP exposes/.well-known/openid-configuration - PKCE: always enabled
- Response type:
code - Default scopes:
[:openid, :email, :profile]; override viasettings.scopes - Groups claim: when
settings.role_mappingis set orgroupsis in the scope list,claimsparameters requestinggroupsin bothid_tokenanduserinfoare appended asextra_authorize_params - Prompt: optional, set via
settings.prompt
SSL options from Rails.configuration.x.ssl are injected directly into client_options.ssl.
SSL/TLS Configuration#
SSL settings are global to the Rails process and configured at boot by config/initializers/00_ssl.rb.
| Env var | Default | Effect |
|---|---|---|
SSL_CA_FILE | — | Path to a PEM-format custom CA or CA chain |
SSL_VERIFY | true | Set to false to disable certificate verification (dev/test only) |
SSL_DEBUG | false | Enables verbose SSL logging |
When SSL_CA_FILE is valid, the initializer merges it with system CAs into a combined bundle at tmp/ssl_ca_bundle.pem and sets ENV["SSL_CERT_FILE"] globally. This is intentional — it ensures gems like openid_connect that bypass SslConfigurable still trust the custom CA during OIDC discovery .
The SslConfigurable concern provides helpers (faraday_ssl_options, httparty_ssl_options, net_http_verify_mode) for HTTP clients that do go through Rails configuration. SsoProvider extends this concern for its Faraday-based discovery validation .
Security note:
SSL_VERIFY=falseremoves MITM protection and is not safe for production. The recommended path for self-hosted deployments with internal CAs isSSL_CA_FILEwith a PEM certificate.
HTTP-Only Providers#
The SsoProvider model validates issuer URLs permissively — accepting both http:// and https:// schemes . However, the underlying openid_connect gem enforces HTTPS for discovery and token requests. There is no built-in option to force HTTP-mode discovery; SSL_VERIFY=false only relaxes certificate validation, it does not downgrade the transport protocol.
Key Files#
| File | Purpose |
|---|---|
config/auth.yml | Static OIDC provider declarations and env var bindings |
app/models/oidc/provider_options_builder.rb | Assembles OmniAuth option hash from raw config |
app/services/provider_loader.rb | Loads providers from YAML or DB with caching |
config/initializers/omniauth.rb | Registers providers with OmniAuth middleware |
config/initializers/00_ssl.rb | Boot-time SSL config; sets SSL_CERT_FILE globally |
app/models/concerns/ssl_configurable.rb | SSL helper concern for Faraday/HTTParty/Net::HTTP clients |
app/models/sso_provider.rb | DB-backed provider model; validates fields and converts to OmniAuth config |