Repository navigation
fix: scope OAuth client admin routes to the caller's tenant - #450
Conversation
A client linked to an identity takes that identity's tenant, but get, list, rotate-secret and delete acted on any client. When the caller has a tenant in context, these routes now only act on unlinked clients or clients whose linked identity is in that tenant; others answer like a missing client. Callers with no tenant in context keep today's behaviour. Fixes #433
|
@RyoKusnadi could you fix one more case in this PR? Deleting an identity makes its linked clients global. Expected: deleting an identity removes its linked OAuth clients, or at least stops them being reachable from other tenants. Points to weigh:
|
oauth_clients.identity_id was ON DELETE SET NULL, so a hard delete of an identity turned its linked clients into unlinked ones, which the tenant scope rule treats as global. Make the foreign key ON DELETE CASCADE so the clients go with the identity. Signed-off-by: Ryo Kusnadi <ryokusnadi@gmail.com>
|
Thanks @rsharath, pushed 237bd1c. Migration 061 changes What I checked:
Test: |
Fixes #433.
A client linked to an identity takes that identity's tenant, but
GET /oauth/clients,GET /oauth/clients/{id},POST .../rotate-secretandDELETE /oauth/clients/{id}acted on any client. A caller in tenant B could rotate the secret of a client linked into tenant A.Changes
IdentityService.GetIdentitiesByIDs).UpdateClienthas no HTTP route, and the RFC 7592 dynamic-client routes authenticate with the per-client registration token, so I left them unchanged.Tests
New integration test
tests/integration/oauth_client_tenant_scope_test.go: tenant B gets 404 on get and rotate for a client linked into tenant A, is left out of list, and delete leaves the client in place. An unlinked client stays global. The full integration suite and the handler and service unit tests pass.