Add SSO/shared identity foundation: code, UUID, and auth_sub fields#76
Closed
Add SSO/shared identity foundation: code, UUID, and auth_sub fields#76
Conversation
… visibility, management commands Co-authored-by: joisemp <69669027+joisemp@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add initial SSO identity groundwork for shared space
Add SSO/shared identity foundation: code, UUID, and auth_sub fields
Mar 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lays the non-breaking groundwork for cross-app shared identity and future SSO integration. All new fields are nullable with no unique constraints — enforcement deferred until after backfill.
Models & Migration (
0014_sso_identity_fields)OrganizationcodeCharField(50)— human-managed short codeOrganizationorg_uuidUUIDField,db_indexSpacecodeCharField(50)— human-managed short codeSpacespace_uuidUUIDField,db_indexUserauth_subCharField(255),db_index— stable Auth/SSO subject identifierAdmin
OrganizationAdmin/SpaceAdmin:codeadded tolist_displayandsearch_fields; new SSO / Shared Identity fieldset exposescodeand the uuid field for manual management.Management Commands
export_identity_data— dumps orgs/spaces to JSON or CSV (stdout or file) withlegacy_id,code,uuid,name,slugfor bootstrapping the Auth service.backfill_identity_fields— idempotent; generates slug-derived placeholder codes and random UUIDs for rows with blank values.Original prompt
Implement initial SSO/Shared Space identity groundwork in joisemp/services.
Context:
Goal of this PR
Add all non-breaking fields needed for cross-app shared identity and future SSO integration:
Scope (requirements)
A) Models/Migrations
code(CharField, nullable, globally unique, human-managed)org_uuid(UUIDField, nullable, db_index)code(CharField, nullable, globally unique, human-managed)space_uuid(UUIDField, nullable, db_index)auth_sub(CharField or UUIDField, nullable, db_index)B) Admin
C) Management command(s)
D) Docs
E) Tests
Notes:
Codes and UUIDs to be filled according to later Auth-side registry and migration plan.
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: 1. both have a unique ids also store space uuid
Assistant: Great — if both already have a stable unique id for Space/Institution, and you want to store
space_uuiddirectly in BusNest (and Services too), here’s the clean, non-breaking plan.Goal
space_uuidin app tables so filtering/permissions can use UUIDs (future-proof)1) Choose the canonical key and UUID source of truth
Since both have a unique id, use this matching key to unify:
Canonical match key (recommended):
org_unique_id + space_unique_id(or institution id)(organisation.slug, space.slug)or(org.code, space.code)UUID creation strategy (important)
To ensure both apps generate the same UUID without manual mapping:
Example namespace approach:
uuid5(NAMESPACE, f"{org_uid}:{space_uid}")This way:
No existing data breaks because this UUID is an additional column.
2) Changes in Services (Spaces)
Add field
Add to
Spacemodel:space_uuid = UUIDField(null=True, unique=True, db_index=True)Migration steps
space_uuidnull=False(after backfill)This does not touch the current
idPK.3) Changes in BusNest (Institutions)
Do the same:
space_uuidto Institution model (even if model name remains Institution)Then you can start using
space_uuidfor cross-app identity and for Auth-based permissions.4) Store
space_uuidin “downstream” tables (gradually)You said “also store space uuid” — typically you’ll add it to models that currently FK to Space/Institution, for example:
Non-breaking pattern
For each table ...
This pull request was created from Copilot chat.
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.