Commit 08cdb8a
authored
feat: self-service sign-up to tenant creation end-to-end flow (#2126)
* feat: defer identity creation to post-provisioning hook for async tenant registration
When a user self-registers and the tenant requires async schema provisioning,
the registration handler now stores the admin email and password hash in
tenant metadata instead of attempting to create the identity immediately
(which would fail because the tenant schema doesn't exist yet).
A new post-provisioning hook reads the stored credentials after schema
provisioning completes and creates the self-registered admin identity with
tenant-owner role, then clears the credentials from metadata.
This completes the end-to-end self-service sign-up flow:
1. User submits registration form
2. Tenant created with provisioning_pending status + credentials in metadata
3. Provisioning worker creates schemas, runs migrations, seeds reference data
4. Self-registered admin hook creates the admin identity
5. Platform admin hook provisions platform admin (existing behavior)
6. Tenant becomes active
7. User sees provisioning progress page, auto-redirects to login on completion
* fix: address review feedback - credential cleanup and metadata safety
- Make metadata conversion failure fatal in loopbackTenantCreator
(prevents silent registration failure for async provisioning)
- Add ClearTenantMetadata to TenantCreator interface and clear
credentials from tenant metadata after sync identity provisioning
- Make clearRegistrationMetadata failure fatal in post-provisioning
hook (enforces minimal credential retention)
- Export metadata key constants from bootstrap package and add
cross-package sync test against gateway constants
- Reuse existing tenant repo in wire_services.go
- Add nil tenant repo validation test
- Remove placeholder test with no coverage
* refactor: replace concrete tenant repo with TenantMetadataStore interface
Replace direct dependency on *tenantpersistence.Repository with a
TenantMetadataStore interface defined in the identity bootstrap package.
This fixes the cross-service domain import architecture violation
(identity -> tenant/adapters/persistence).
Add GetMetadata convenience method on tenant repository to satisfy
the new interface without exposing full domain objects.
* fix: async path respects email verification, harden metadata handling
- Store emailVerificationRequired in tenant metadata so the
post-provisioning hook creates PENDING_VERIFICATION identities
when email verification is enabled (fixes bypass on async path)
- Fail hook on partial/malformed registration metadata instead of
silently succeeding (prevents orphaned tenants without admin)
- Remove raw email addresses from hook log messages (PII)
- Add MetaKeyRegistrationEmailVerifyRequired constant with sync test
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent 007371e commit 08cdb8a
8 files changed
Lines changed: 556 additions & 54 deletions
File tree
- cmd/meridian
- services
- api-gateway
- identity/bootstrap
- tenant/adapters/persistence
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
204 | 206 | | |
205 | 207 | | |
206 | 208 | | |
| 209 | + | |
207 | 210 | | |
208 | 211 | | |
209 | 212 | | |
210 | 213 | | |
211 | | - | |
| 214 | + | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | 219 | | |
217 | | - | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
221 | 224 | | |
222 | 225 | | |
223 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
224 | 240 | | |
225 | | - | |
| 241 | + | |
226 | 242 | | |
227 | 243 | | |
228 | | - | |
| 244 | + | |
229 | 245 | | |
230 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
231 | 250 | | |
232 | 251 | | |
233 | 252 | | |
| |||
238 | 257 | | |
239 | 258 | | |
240 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
241 | 271 | | |
242 | 272 | | |
243 | 273 | | |
| |||
291 | 321 | | |
292 | 322 | | |
293 | 323 | | |
294 | | - | |
295 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
296 | 327 | | |
297 | 328 | | |
298 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
62 | 65 | | |
63 | 66 | | |
64 | 67 | | |
| |||
69 | 72 | | |
70 | 73 | | |
71 | 74 | | |
72 | | - | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | | - | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
85 | 89 | | |
86 | 90 | | |
87 | 91 | | |
88 | | - | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
99 | | - | |
| 106 | + | |
100 | 107 | | |
101 | 108 | | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
111 | 119 | | |
112 | 120 | | |
113 | 121 | | |
114 | | - | |
| 122 | + | |
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
119 | 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 | + | |
120 | 153 | | |
121 | 154 | | |
122 | 155 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
246 | 256 | | |
247 | 257 | | |
248 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
43 | | - | |
44 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
48 | 61 | | |
49 | 62 | | |
50 | 63 | | |
| |||
119 | 132 | | |
120 | 133 | | |
121 | 134 | | |
| 135 | + | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
| |||
155 | 169 | | |
156 | 170 | | |
157 | 171 | | |
158 | | - | |
| 172 | + | |
159 | 173 | | |
160 | 174 | | |
| 175 | + | |
161 | 176 | | |
162 | 177 | | |
163 | 178 | | |
| |||
185 | 200 | | |
186 | 201 | | |
187 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
188 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
189 | 217 | | |
190 | 218 | | |
191 | 219 | | |
| |||
194 | 222 | | |
195 | 223 | | |
196 | 224 | | |
197 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
198 | 241 | | |
199 | 242 | | |
200 | 243 | | |
| |||
204 | 247 | | |
205 | 248 | | |
206 | 249 | | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
213 | 271 | | |
214 | | - | |
215 | 272 | | |
216 | 273 | | |
217 | 274 | | |
| |||
220 | 277 | | |
221 | 278 | | |
222 | 279 | | |
223 | | - | |
| 280 | + | |
224 | 281 | | |
225 | 282 | | |
| 283 | + | |
226 | 284 | | |
227 | 285 | | |
228 | 286 | | |
| |||
240 | 298 | | |
241 | 299 | | |
242 | 300 | | |
243 | | - | |
| 301 | + | |
| 302 | + | |
244 | 303 | | |
245 | 304 | | |
246 | 305 | | |
| |||
250 | 309 | | |
251 | 310 | | |
252 | 311 | | |
253 | | - | |
| 312 | + | |
254 | 313 | | |
255 | 314 | | |
256 | 315 | | |
| |||
273 | 332 | | |
274 | 333 | | |
275 | 334 | | |
276 | | - | |
277 | | - | |
278 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
279 | 338 | | |
280 | 339 | | |
281 | 340 | | |
| |||
287 | 346 | | |
288 | 347 | | |
289 | 348 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
| 349 | + | |
297 | 350 | | |
298 | 351 | | |
299 | 352 | | |
| |||
0 commit comments