You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The gem's Rails engine handles several things so host apps don't have to:
58
56
59
-
Fill in at minimum `issuer`, `client_id`, and an `on_login` hook. Full reference below.
57
+
***OmniAuth strategy registration** — the engine registers the `:openid_connect` strategy with Devise automatically based on your `ActiveAdmin::Oidc` configuration. You do **not** need to add `config.omniauth` or `config.omniauth_path_prefix` to `devise.rb`.
58
+
***Callback controller** — the engine patches `ActiveAdmin::Devise.controllers` to route OmniAuth callbacks to the gem's controller. No manual `controllers: { omniauth_callbacks: ... }` needed in `routes.rb`.
59
+
***Login view override** — the engine prepends an SSO-only login page (no email/password fields) to the sessions controller's view path. If your host app ships its own `app/views/active_admin/devise/sessions/new.html.erb`, the gem detects it and backs off — your view wins.
60
+
***Path prefix** — the engine sets `Devise.omniauth_path_prefix` and `OmniAuth.config.path_prefix` to `/admin/auth` so the middleware intercepts requests under ActiveAdmin's mount point. Compatible with Rails 7.2+ and Rails 8's lazy route loading.
61
+
***Parameter filtering** — `code`, `id_token`, `access_token`, `refresh_token`, `state`, and `nonce` are added to `Rails.application.config.filter_parameters`.
60
62
61
63
## Configuration
62
64
@@ -70,6 +72,11 @@ ActiveAdmin::Oidc.configure do |c|
|`identity_attribute`|`:email`| AdminUser column used for lookup/adoption |
110
118
|`identity_claim`|`:email`| Claim key read from the id_token/userinfo |
111
119
|`admin_user_class`|`"AdminUser"`| String or Class for the host's admin user model |
@@ -218,8 +226,84 @@ AdminUser.last.oidc_raw_info
218
226
* A login button is added to the ActiveAdmin sessions page via a prepended view override — no templates to edit.
219
227
* Clicking it POSTs to `/admin/auth/oidc` with a Rails CSRF token. The gem loads `omniauth-rails_csrf_protection` so OmniAuth 2.x delegates its authenticity check to Rails' forgery protection and `button_to` just works.
220
228
* After a successful callback the user is signed in and redirected to `/admin` (not the host app's `/`, which may not exist).
229
+
***Disabled/locked users are rejected.** Devise's `active_for_authentication?` is checked after provisioning but before sign-in. If your model overrides this method (e.g. to check an `enabled` flag or Devise's `:lockable` module), the guard fires on OIDC sign-in too — the user sees an appropriate flash and is redirected to the login page.
221
230
* Logout goes through Devise's stock session destroy. No RP-initiated single-logout ping to the IdP — override the destroy action in your host app if you need that.
222
231
232
+
## Custom login view
233
+
234
+
The gem ships a minimal SSO-only login page (a single button, no email/password fields). If you need a different layout — for instance, a combined SSO + password form for a break-glass mode — drop your own template at:
The default job should exclude them: `bundle exec rspec --tag ~oidc_mode`.
306
+
223
307
## Security notes
224
308
225
309
### Choice of `identity_attribute`
@@ -238,7 +322,7 @@ The gem also adds a unique `(provider, uid)` partial index in its own install mi
238
322
239
323
### What's filtered from logs
240
324
241
-
The initializer merges `code`, `id_token`, `access_token`, `refresh_token`, `state`, and `nonce` into `Rails.application.config.filter_parameters` so a mid-callback crash can't dump them into production logs. Your own `filter_parameters` entries are preserved.
325
+
The engine merges `code`, `id_token`, `access_token`, `refresh_token`, `state`, and `nonce` into `Rails.application.config.filter_parameters` so a mid-callback crash can't dump them into production logs. Your own `filter_parameters` entries are preserved.
0 commit comments