Commit 1859c1b
authored
Create MemberOidcProvisioner Service (#342)
## Overview
Implements **Story 2: MemberOidcProvisioner Service** from the [Member
SSO Implementation
Stories](../architecture/staff-sso/member-sso-stories.md).
This PR adds a provisioner service that creates or updates member users
from citizen IdP OIDC claims, following the same pattern as
`StaffUserProvisioner` but without role mapping logic.
## Changes
### New Files
| File | Description |
|------|-------------|
| `app/services/member_oidc_provisioner.rb` | Provisioner service for
member OIDC users |
| `spec/services/member_oidc_provisioner_spec.rb` | Comprehensive test
coverage |
### Modified Files
| File | Description |
|------|-------------|
| `spec/support/sso_helpers.rb` | Added member OIDC test helpers |
## Implementation Details
### `MemberOidcProvisioner`
```ruby
provisioner = MemberOidcProvisioner.new
user = provisioner.provision!(claims)
# claims: { uid:, email:, name: }
```
**Behavior:**
- Finds existing users by `uid` (not email) to handle email changes
correctly
- Creates new user with `provider: "member_oidc"` if not found
- Updates `email` and `full_name` on every login
- Sets `mfa_preference ||= "opt_out"` so IdP handles MFA (no app MFA
challenge)
- Does NOT set or change `role` (members have no staff role)
- Validates required claims (`uid`, `email`) and raises `ArgumentError`
if missing
- Does NOT raise for "no role" (unlike `StaffUserProvisioner` with deny
mode)
**Key difference from `StaffUserProvisioner`:**
| Aspect | StaffUserProvisioner | MemberOidcProvisioner |
|--------|---------------------|----------------------|
| Provider | `"sso"` | `"member_oidc"` |
| Role mapping | Uses `RoleMapper` | None (no role logic) |
| Access denied | Raises if no matching role | Never raises for role |
| Groups claim | Required for role | Not used |
| Region claim | Synced if present | Not used |
### Test Helpers Added to `sso_helpers.rb`
| Helper | Purpose |
|--------|---------|
| `mock_member_claims(overrides = {})` | Mock claims for provisioner
tests |
| `mock_member_omniauth_hash(overrides = {})` | Mock OmniAuth auth hash
for controller tests |
| `setup_member_omniauth_mock(auth_hash = nil)` | Configure OmniAuth
test mode for member OIDC |
| `setup_member_omniauth_failure(message)` | Configure OmniAuth failure
for member OIDC |
| `reset_member_omniauth` | Reset member OIDC mock auth |
| `reset_all_omniauth` | Reset both SSO and member OIDC mocks |
| `mock_member_oidc_config(overrides = {})` | Mock
`Rails.application.config.member_oidc` |
| `configure_member_oidc_for_test(config = nil)` | Stub member OIDC
config in tests |
## Acceptance Criteria
| Criteria | Status |
|----------|--------|
| `provision!(claims)` accepts `{ uid:, email:, name: }` | ✅ |
| Finds user by `uid`; if not found, creates with `provider:
"member_oidc"` | ✅ |
| On every call, updates `email` and `full_name` from claims | ✅ |
| Does not set or change `role` | ✅ |
| Sets `user.mfa_preference ||= "opt_out"` | ✅ |
| Returns the user; does not raise for "no role" | ✅ |
| Validates required claims (uid, email) and raises `ArgumentError` if
missing | ✅ |
## Test Coverage
| Scenario | Tests |
|----------|-------|
| First login creates user with correct provider and attributes | ✅ |
| Subsequent login finds by UID and updates email/name | ✅ |
| Email change in IdP updates user (match by UID) | ✅ |
| New and existing member OIDC users get `mfa_preference` set to
`opt_out` | ✅ |
| Raises when uid or email missing | ✅ |
| Preserves existing role if user was previously staff | ✅ |
<!-- reporting-app - begin PR environment info -->
## Preview environment for reporting-app
- Service endpoint:
https://p-342-reporting-app-dev-1854866940.us-east-1.elb.amazonaws.com
- Deployed commit: 8c90693
<!-- reporting-app - end PR environment info -->1 parent 50a939e commit 1859c1b
File tree
3 files changed
+287
-3
lines changed- reporting-app
- app/services
- spec
- services
- support
3 files changed
+287
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
Lines changed: 205 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
| 3 | + | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
| |||
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
109 | | - | |
| 120 | + | |
110 | 121 | | |
111 | 122 | | |
112 | 123 | | |
| 124 | + | |
113 | 125 | | |
114 | 126 | | |
0 commit comments