Phase 1 (backend): identity, teams & ownership#9
Merged
Conversation
Add the identity layer that gates the rest of the roadmap: real users, teams/workspaces, roles, ownership, and audit FKs. Single-tenant per deployment (isolation by workspace_id within an auto-created default org); organization_id carried on every core table so a future managed-SaaS fleet needs no migration. Auth: magic-link + local password login issuing HS256 session JWTs delivered as HTTP-only cookies; OIDC is a registered (unimplemented) provider seam; DISABLE_AUTH escape hatch for local dev. - Models: Organization, User, Team, Membership (admin|editor|viewer), ApiKey - Core: security.py (PBKDF2 + JWT + API keys), auth.py (get_current_user / get_org_context / require_role + cookie helpers), auth_providers.py seam - Services: auth_service (login/magic-link/register), identity_service (org/team/membership/api-key CRUD, bootstrap + system_context) - Endpoints: /auth/*, /teams (+members), /api-keys - AuthZ wired through connection_service, query/schema services, all metadata endpoints (via connection cascade root), the MCP server, and startup auto-setup (system context). created_by/user_id promoted to real User FKs. - Migration 004: nullable -> seed default org/workspace/admin -> backfill -> NOT NULL, with (org_id, created_at) indexes and a full downgrade. - Tests: password/JWT/API-key crypto, provider registry, role hierarchy, 401 on protected routes (98 pass). - docker-compose: DISABLE_AUTH=true bridge until the Phase 1 frontend lands. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Implements the backend half of Phase 1 from
planfull.md— the identity layer that gates the rest of the roadmap.Decisions (confirmed)
What's included
Organization,User,Team(= workspace),Membership(admin|editor|viewer),ApiKey. Single-tenant per deployment (isolation byworkspace_id);organization_idcarried on every core table so a future managed-SaaS fleet needs no migration.app/core/security.py(PBKDF2 passwords, HS256 JWTs with apurposeclaim, API-key gen/hash),app/core/auth.py(get_current_user→ API key/Bearer/cookie,get_org_context→AuthContext,require_role, cookie helpers,DISABLE_AUTHdev escape hatch), and the pluggableapp/core/auth_providers.pyseam.auth_service,identity_service(incl.bootstrap_default_identity+system_context); routes/auth/*,/teams(+ members),/api-keys.connection_servicescopes by org+workspace and enforces role; metadata endpoints authorize via the connection cascade root (app/api/v1/deps.py); query/schema services, all endpoints, the MCP server, and startup auto-setup threadAuthContext.created_by/user_idpromoted to realUserFKs.004— nullable → seed default org/workspace/admin → backfill → NOT NULL, with(org_id, created_at)indexes and a full downgrade.Verification
created_by).ruff/mypyclean on new files.Deploy note
Once migration 004 runs, auth is mandatory. The pre-auth frontend would 401, so
docker-compose.ymlsetsDISABLE_AUTH=trueas the bridge until the frontend PR lands.🤖 Generated with Claude Code