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
{{ message }}
Repository navigation
Control plane: spike — should Cognito identity ownership move out of MDR? (ADR extending 0002) #1190
Part of #1041. Design spike — the epic and ADR 0002 both call this out as the bigger open question, deliberately deferred.
Why
ADR 0002: "Identity ownership is the bigger open question. The Cognito self-serve identity is MDR's today." Moving developer keys is mechanical once #1180 lands; moving identity is not. The self-serve tenant flow (#882/#883/#884, docs/design/cross-cutting/self-serve-tenant-auth.md) spans Cognito sign-up, schema-per-tenant provisioning, workspace selection, and invite tokens — and tenant provisioning is genuinely an MDR concern, while sign-in is genuinely a control-plane concern.
Questions to answer
Which parts of the self-serve flow are identity (control plane) and which are tenant/metadata provisioning (MDR)? The seam is not obvious — /tenants/provision needs both.
Who owns the Cognito user pool, and what happens to existing users and sessions in a move?
How do invite tokens and workspace selection work across the split?
Is a move even warranted, or is "identity stays with MDR, keys move" a defensible end state? This spike is allowed to conclude "don't move it" — that is a real outcome, not a failure.
Migration cost and blast radius: this touches live sign-in for both environments.
Done when
An ADR extending 0002 records the decision with its reasoning, and — if a move is recommended — a sized set of follow-on issues exists. If not, #1041 is amended to drop identity from its scope.
Note
Do not start this before the key extraction (#1180) and the service (#1182) are done. Sequencing it first is how this epic stalls.
Input for this spike: a non-Cognito local-login path is being added to MDR in #1316, so a deployer can test-drive LIF with username/password logins they configure, with no Cognito and a single schema.
Today MDR's HS256 /login checks a hardcoded list of demo users against one shared password (bases/lif/mdr_restapi/core.py). #1316 makes that list configurable. If this spike concludes that sign-in should move out of MDR to the control plane, that local-login path has to move with it and keep working. It's the only way into a Cognito-less deployment. Please treat it as a requirement on whatever identity split comes out of this, not only the Cognito self-serve flow.
(#1185 doesn't touch it: that issue moves developer API keys, a different domain from user sign-in.)
ADR 0006 gives this spike one concrete question that #1183 is waiting on: what identifies a workspace in the control plane's key store, and how does issuance confirm the caller belongs to it?
Today the check maps the caller's Cognito group to a schema with tenant_schema_for_group (components/lif/tenant_routing/core.py:45). The ADR deliberately doesn't choose between the tenant_* schema name, the Cognito group, and a new ID. It also says the control plane shouldn't inherit MDR's tenant_* naming by default.
One constraint, from bjagg's 09-26 comment about local logins: an HS256 or local-login user has no cognito:groups claim. resolve_tenant_schema sends such callers to the service schema (components/lif/tenant_routing/core.py:58). So a workspace defined as "the Cognito group" can't work in a Cognito-less deployment. Whatever this spike picks has to work for both login paths.
Sequencing. The issue's note still holds: don't start the spike before #1180 and #1182. But #1183 can't finish without this one answer, so I'd answer the workspace question first, before the rest of the identity split.
Out of scope until #1182 lands: the wider identity split. That covers who owns the user pool, the self-serve flow seam, invite tokens across the split, and whether sign-in moves at all.
I'll post the findings here as a recommendation with the code it's grounded in. The ADR extending 0002 comes once the full spike can run, unless you'd rather the workspace answer get its own ADR now.
@bjagg findings on the workspace question, the slice I took on above. This doesn't cover the wider identity split. It's grounded on main at 588757a.
What a workspace is today
Nothing in the database records a workspace. It's the pair (Cognito group, tenant_{sanitized group} schema), worked out on each request (components/lif/mdr_services/workspace_service.py:22-27, components/lif/tenant_routing/core.py:28-55). None of the migrations V1.0–V1.6 creates a workspace or tenant table, so the schema itself is the only durable record.
When a user is in several groups, the MDR picks one with the lif_workspace cookie. The cookie is HMAC-signed with the JWT secret and is rechecked against cognito:groups on every request (components/lif/mdr_auth/workspace_cookie.py:51-53, components/lif/mdr_auth/core.py:291-298). With no cookie, the first group wins.
Each kind of caller ends up at a schema:
Caller
What request.state gets
Schema
Cognito JWT
principal (email or sub), cognito_groups, cognito_sub (mdr_auth/core.py:237-239)
principal = sub = the username. No groups, no cognito_sub (mdr_auth/core.py:240-248; /login at bases/lif/mdr_restapi/core.py:418)
the service schema
Service API key
service:<name> (mdr_auth/core.py:199-205)
X-API-Tenant-Schema, or the service schema
Issuing a key today depends on request.state.cognito_sub and returns a 400 without it (bases/lif/mdr_restapi/developer_api_key_endpoints.py:20-29). The key's workspace is whichever schema search_path picked; the row has no workspace column (V1.5:14-24).
Recommendation: the tenant schema name, stored as an opaque string
I'm proposing this for the workspace column that ADR 0006 leaves open, with the two questions below.
It's the only identifier every caller already has. Cognito users get it through the group. Local logins get it through the service schema. Service callers already pass it in X-API-Tenant-Schema.
It's what a key's consumers route on. The LDE and the Translator reach the MDR by schema name (components/lif/translator_client/core.py:39, components/lif/mdr_client/core.py:48-53).
On ADR 0006's caution about inheriting MDR's tenant_* naming: the control plane would treat the value as opaque. It would never parse or build the prefix itself. The group-to-schema rule stays in the pure tenant_routing brick, which the control plane can import without depending on MDR.
Issuance would check membership like this:
The request names the workspace explicitly. The control plane can't read lif_workspace, because that cookie is signed with MDR's secret.
A Cognito caller is allowed if one of their groups satisfies tenant_schema_for_group(group) == workspace. That's the same rule find_workspace applies today.
local logins have no group, so it can't work in a Cognito-less deployment;
renaming a group orphans the workspace;
two names can map to one schema (see finding 2 below).
A new control-plane workspace ID, a Workspaces table that maps an ID to a schema and an IdP group. Deferred, not rejected. It's the most correct shape, but owning workspace records is the identity-ownership question this spike is holding until Control plane: create the control-plane service (base + project + deploy pipeline) #1182. If that half adopts it, it's a one-time backfill from the schema names.
Two group names can map to the same schema. I measured tenant_schema_for_group("Foo-Bar") and tenant_schema_for_group("foo_bar"): both return tenant_foo_bar, and nothing detects it. This exists in MDR today, independent of the control plane. I can file it separately if you agree it's worth tracking.
Two questions before I take this further
Q1: Should local-login users be able to issue developer keys at all? Today they can't. Finding 1 only matters if the answer is yes.
Q2: Is the schema name, stored as an opaque string, acceptable as the workspace identifier for now, despite ADR 0006's caution? A dedicated workspace ID would then be revisited in the identity half.
Once you've answered, I'll record the decision where you prefer. That could be a short ADR now, since #1183 needs it, or part of the ADR extending 0002 when the rest of this spike runs.
@bjagg a nudge on Q1 and Q2 from my 10-07 comment above, because #1182 now depends on them too. I've claimed #1182 and am starting the control-plane service without its key endpoints.
The key table I'd add next has to choose two columns, and each one depends on an open question:
Workspace: ADR 0006 gives the store an explicit workspace column, and its value is Q2. My recommendation is the tenant schema name, stored as an opaque string.
Owner: whether OwnerSub stays a bare Cognito sub or becomes issuer-qualified (cognito:<sub> / local:<username>) depends on Q1, whether local-login users can issue keys.
Both are cheap to decide now and expensive to change after a migration ships. The service skeleton doesn't need either answer, so nothing is blocked yet. Once you've answered, I'll record the decision wherever you prefer, as a short ADR now or as part of the ADR extending 0002.
@bjagg, a second nudge on Q1 and Q2 from my 10-07 comment (issuecomment-6048941868). They are now the only thing blocking the next slice of #1182.
Where things stand. The control-plane skeleton, draft #1384, is up to date: main is merged in, and it's moved onto lif.auth since #1398 deleted cognito_auth. Its tests and the local compose run are green. The next step is the developer-key table and its endpoints, and that migration has to fix two columns:
Q2, the workspace column: is the tenant schema name, stored as an opaque string, acceptable as the workspace identifier for now? The control plane would never parse or build the tenant_ prefix. A dedicated workspace ID would be revisited in the identity half of this spike.
To make it a quick answer, my defaults are Q1 = no and Q2 = yes. They are the smallest change from what runs today. The one catch: if Q1 later becomes yes, the owner column has to be rewritten, so say so now if local-login key issuance is on the roadmap. If those defaults work for you, a 👍 on this comment is enough. I'll then record the decision as a short ADR, since #1183 needs it before the rest of this spike runs, and write the key-table migration.
Both answers are cheap now and expensive after a migration ships, which is why I'm asking before writing it.
Defaults OK for Q1 and Q2: local-login users can't issue developer keys, so OwnerSub stays a bare Cognito sub, and the tenant schema name, stored as an opaque string, is the workspace identifier for now.
Done: the workspace slice (Q1 and Q2). Bill accepted the defaults on 11-03, and ADR 0008 (docs/design/adr/general/0008-control-plane-key-owner-and-workspace.md) records them:
Local-login users can't issue developer keys, so a key's owner is a bare Cognito sub.
A workspace is identified by its tenant schema name, stored as an opaque string.
The control plane's key endpoints are built on them (#1466, for #1182), and #1183's migration will use the same columns.
Still open: the spike's main question. Should Cognito identity ownership move out of the MDR into the control plane, or stay where it is? This issue's "done when" asks for an ADR extending 0002 on that. Nothing has decided it yet. ADR 0008 deliberately records only the key-store choices and leaves identity ownership here.
I'm leaving this open for that question. It isn't blocking any current #1041 work, so it can wait until the control plane needs it.
Activity
bjagg commentedon Sep 26, 2026
Input for this spike: a non-Cognito local-login path is being added to MDR in #1316, so a deployer can test-drive LIF with username/password logins they configure, with no Cognito and a single schema.
Today MDR's HS256
/loginchecks a hardcoded list of demo users against one shared password (bases/lif/mdr_restapi/core.py). #1316 makes that list configurable. If this spike concludes that sign-in should move out of MDR to the control plane, that local-login path has to move with it and keep working. It's the only way into a Cognito-less deployment. Please treat it as a requirement on whatever identity split comes out of this, not only the Cognito self-serve flow.(#1185 doesn't touch it: that issue moves developer API keys, a different domain from user sign-in.)
dereck-symmetry commentedon Oct 5, 2026
ADR 0006 gives this spike one concrete question that #1183 is waiting on: what identifies a workspace in the control plane's key store, and how does issuance confirm the caller belongs to it?
Today the check maps the caller's Cognito group to a schema with
tenant_schema_for_group(components/lif/tenant_routing/core.py:45). The ADR deliberately doesn't choose between thetenant_*schema name, the Cognito group, and a new ID. It also says the control plane shouldn't inherit MDR'stenant_*naming by default.One constraint, from bjagg's 09-26 comment about local logins: an HS256 or local-login user has no
cognito:groupsclaim.resolve_tenant_schemasends such callers to the service schema (components/lif/tenant_routing/core.py:58). So a workspace defined as "the Cognito group" can't work in a Cognito-less deployment. Whatever this spike picks has to work for both login paths.Sequencing. The issue's note still holds: don't start the spike before #1180 and #1182. But #1183 can't finish without this one answer, so I'd answer the workspace question first, before the rest of the identity split.
dereck-symmetry commentedon Oct 7, 2026
Taking this, but only one slice of it for now. The note above still holds for the rest: #1180 is waiting on #1363 to merge, and #1182 hasn't started.
In scope now: the workspace question from my 10-05 comment, because #1183 can't finish without it.
tenant_*schema name, the Cognito group, or a new ID?cognito:groupsclaim.Out of scope until #1182 lands: the wider identity split. That covers who owns the user pool, the self-serve flow seam, invite tokens across the split, and whether sign-in moves at all.
I'll post the findings here as a recommendation with the code it's grounded in. The ADR extending 0002 comes once the full spike can run, unless you'd rather the workspace answer get its own ADR now.
dereck-symmetry commentedon Oct 7, 2026
@bjagg findings on the workspace question, the slice I took on above. This doesn't cover the wider identity split. It's grounded on
mainat588757a.What a workspace is today
Nothing in the database records a workspace. It's the pair (Cognito group,
tenant_{sanitized group}schema), worked out on each request (components/lif/mdr_services/workspace_service.py:22-27,components/lif/tenant_routing/core.py:28-55). None of the migrations V1.0–V1.6 creates a workspace or tenant table, so the schema itself is the only durable record.When a user is in several groups, the MDR picks one with the
lif_workspacecookie. The cookie is HMAC-signed with the JWT secret and is rechecked againstcognito:groupson every request (components/lif/mdr_auth/workspace_cookie.py:51-53,components/lif/mdr_auth/core.py:291-298). With no cookie, the first group wins.Each kind of caller ends up at a schema:
request.stategetscognito_groups,cognito_sub(mdr_auth/core.py:237-239)tenant_*sub= the username. No groups, nocognito_sub(mdr_auth/core.py:240-248;/loginatbases/lif/mdr_restapi/core.py:418)service:<name>(mdr_auth/core.py:199-205)X-API-Tenant-Schema, or the service schemaIssuing a key today depends on
request.state.cognito_suband returns a 400 without it (bases/lif/mdr_restapi/developer_api_key_endpoints.py:20-29). The key's workspace is whichever schemasearch_pathpicked; the row has no workspace column (V1.5:14-24).Recommendation: the tenant schema name, stored as an opaque string
I'm proposing this for the workspace column that ADR 0006 leaves open, with the two questions below.
X-API-Tenant-Schema.components/lif/translator_client/core.py:39,components/lif/mdr_client/core.py:48-53).On ADR 0006's caution about inheriting MDR's
tenant_*naming: the control plane would treat the value as opaque. It would never parse or build the prefix itself. The group-to-schema rule stays in the puretenant_routingbrick, which the control plane can import without depending on MDR.Issuance would check membership like this:
lif_workspace, because that cookie is signed with MDR's secret.tenant_schema_for_group(group) == workspace. That's the same rulefind_workspaceapplies today.Alternatives considered:
Two findings beyond the question
cognito:<sub>/local:<username>). That changes the Control plane: extract developer-key logic out of MDR-domain bricks into a portabledeveloper_keysbrick #1180 brick's model and Control plane: migrate the developer-key store to control-plane-owned storage (dev + demo, non-destructive) #1183's copy, where existingOwnerSubvalues would becomecognito:<sub>.tenant_schema_for_group("Foo-Bar")andtenant_schema_for_group("foo_bar"): both returntenant_foo_bar, and nothing detects it. This exists in MDR today, independent of the control plane. I can file it separately if you agree it's worth tracking.Two questions before I take this further
Once you've answered, I'll record the decision where you prefer. That could be a short ADR now, since #1183 needs it, or part of the ADR extending 0002 when the rest of this spike runs.
Issue #1180: refactor: extract developer-key logic into a portable de…
Issue #1181: docs(adr): accept ADR 0006 and close the gaps from its r…
dereck-symmetry commentedon Oct 13, 2026
@bjagg a nudge on Q1 and Q2 from my 10-07 comment above, because #1182 now depends on them too. I've claimed #1182 and am starting the control-plane service without its key endpoints.
The key table I'd add next has to choose two columns, and each one depends on an open question:
OwnerSubstays a bare Cognitosubor becomes issuer-qualified (cognito:<sub>/local:<username>) depends on Q1, whether local-login users can issue keys.Both are cheap to decide now and expensive to change after a migration ships. The service skeleton doesn't need either answer, so nothing is blocked yet. Once you've answered, I'll record the decision wherever you prefer, as a short ADR now or as part of the ADR extending 0002.
dereck-symmetry commentedon Oct 26, 2026
@bjagg, a second nudge on Q1 and Q2 from my 10-07 comment (issuecomment-6048941868). They are now the only thing blocking the next slice of #1182.
Where things stand. The control-plane skeleton, draft #1384, is up to date: main is merged in, and it's moved onto
lif.authsince #1398 deletedcognito_auth. Its tests and the local compose run are green. The next step is the developer-key table and its endpoints, and that migration has to fix two columns:cognito_sub):OwnerSubstays a bare Cognitosub, and Control plane: migrate the developer-key store to control-plane-owned storage (dev + demo, non-destructive) #1183's copy keeps the existing values unchanged.cognito:<sub>/local:<username>), and Control plane: migrate the developer-key store to control-plane-owned storage (dev + demo, non-destructive) #1183 rewrites the existing values tocognito:<sub>.tenant_prefix. A dedicated workspace ID would be revisited in the identity half of this spike.To make it a quick answer, my defaults are Q1 = no and Q2 = yes. They are the smallest change from what runs today. The one catch: if Q1 later becomes yes, the owner column has to be rewritten, so say so now if local-login key issuance is on the roadmap. If those defaults work for you, a 👍 on this comment is enough. I'll then record the decision as a short ADR, since #1183 needs it before the rest of this spike runs, and write the key-table migration.
Both answers are cheap now and expensive after a migration ships, which is why I'm asking before writing it.
bjagg commentedon Nov 3, 2026
Defaults OK for Q1 and Q2: local-login users can't issue developer keys, so
OwnerSubstays a bare Cognitosub, and the tenant schema name, stored as an opaque string, is the workspace identifier for now.Issue #1182: feat: stand up the control-plane service skeleton with i…
Issue #1190: docs: add ADR 0008, a control-plane key's owner and work…
Issue #1182: feat: serve developer keys from the control plane, scope…
dereck-symmetry commentedon Nov 9, 2026
Status update, so it's clear what's left here.
Done: the workspace slice (Q1 and Q2). Bill accepted the defaults on 11-03, and ADR 0008 (
docs/design/adr/general/0008-control-plane-key-owner-and-workspace.md) records them:sub.The control plane's key endpoints are built on them (#1466, for #1182), and #1183's migration will use the same columns.
Still open: the spike's main question. Should Cognito identity ownership move out of the MDR into the control plane, or stay where it is? This issue's "done when" asks for an ADR extending 0002 on that. Nothing has decided it yet. ADR 0008 deliberately records only the key-store choices and leaves identity ownership here.
I'm leaving this open for that question. It isn't blocking any current #1041 work, so it can wait until the control plane needs it.