review this pr: https://github.com/agentrhq/authsome/issues/354
- User
review this pr: https://github.com/agentrhq/authsome/issues/354
- User
Checkout this issue: https://github.com/agentrhq/authsome/issues/354
Assistant
Fetching the issue details now.
Assistant
Let me explore the relevant files to understand the current state of the dependency injection.
Assistant
Now let me look at the app.py and a few route files to see how dependencies flow.
Assistant
Let me check the remaining route files and grep for all usages of key app state fields.
Assistant
Let me read
ui.pyandstore/repositories.pyto complete my picture.Assistant
Now I have a full understanding. Let me grep for all usages of
ResolvedOwnershipto safely make it optional.Assistant
Let me check the specific
ui.pyusage ofbuild_auth_serviceandget_auth_service.Assistant
Now I have a complete understanding of the issue. Here's the breakdown:
Problems:
get_protected_auth_servicedoes 5 things: PoP JWT validation, registration check, ownership resolution,request.statepopulation, and service construction.- Four
app.statealiases (identity_registry,vault_registry,identity_claim_registry,principal_vault_binding_registry) shadowapp.state.store.*causing inconsistent access patterns. get_auth_service's principal-id path bypassesOwnershipResolverand does inline registry lookups.get_admin_auth_servicechainsget_protected_auth_serviceas a direct call rather than a FastAPI dependency.resolve_ui_request_identityalways returnsNonebut its return type saysstr | None.
Let me implement the fix.
Assistant
Now add
resolve_for_principaltoOwnershipResolver:Assistant
Now remove the redundant
app.statealiases fromapp.pyand fix thecreate_identity_bootstrap_servicecall:Assistant
Now rewrite
routes/_deps.py— the main refactor:Assistant
Now fix
routes/auth.py— changevault_registrytostore.vaults:Assistant
Now fix
routes/ui.py— changeidentity_claim_registrytostore.identity_claims:Assistant
Also fix
ui.py's_resolve_ui_authto not treat the return value ofresolve_ui_request_identityas an identity:Assistant
Now run the tests and checks to verify nothing broke:
Assistant
All 365 tests pass. Now run lint and type checks:
Assistant
All clean. Here's a summary of what was changed and why:
ownership.pyResolvedOwnership.identity:str→str | None— UI/account callers have no cryptographic identity, only a principal from email+password auth.- Added
OwnershipResolver.resolve_for_principal(principal_id)— centralizes the principal→vault lookup that was previously inlined in_deps.py, so both resolution paths go through the ownership resolver.
app.py- User
/effort effort
- User
/effort effort medium
- User
commit and push
Assistant
Committed and pushed as
e9498bbonrefactor/simplify-server. Pre-commit hooks (ruff lint + format, secrets scan) all passed.