Repository navigation
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
authup
@authup/client-account-console
@authup/client-admin-console
@authup/client-auth-console
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
dc35461 to
0a42537
Compare
There was a problem hiding this comment.
Pull request overview
Adds an explicit usedClientId query parameter to the sessions list and bulk-revoke endpoints so operators can target “every session that a given application served,” even when the session’s own clientId is write-once and only reflects the first authorizing client. This builds on the auth_session_tokens.client_id attribution introduced in the stacked base PR.
Changes:
- Extend session listing (
GET /sessions) to accept?usedClientId=<id[,id...]>and apply it as a mandatory constraint. - Extend session bulk deletion (
DELETE /sessions) sousedClientIdalone selects the admin bulk-revoke path (permission-gated), applying the same constraint. - Add a unit test covering the gap where
filter[clientId]cannot find sessions served (but not created) by a later application.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| apps/server-core/test/unit/http/controllers/workflows/token/session-token-attribution.spec.ts | Adds coverage proving usedClientId finds and revokes sessions served by a second app on the same browser session. |
| apps/server-core/src/core/entities/session/types.ts | Introduces SessionGetManyOptions.usedClientIds and threads usedClientIds through delete options. |
| apps/server-core/src/core/entities/session/service.ts | Plumbs usedClientIds through getMany() and ensures usedClientId selects the admin bulk-delete path. |
| apps/server-core/src/core/authentication/session/types.ts | Extends repository options to include usedClientIds and updates findAllByQuery signature accordingly. |
| apps/server-core/src/app/modules/authentication/repositories/session.ts | Implements the (session.client_id IN ...) OR EXISTS(auth_session_tokens...) constraint via a bracketed AND clause. |
| apps/server-core/src/adapters/http/controllers/entities/session/module.ts | Parses usedClientId (single / repeated / comma-list) and passes it to service methods for GET + DELETE. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
29d7252 to
8363794
Compare
Sessions could only be found by auth_sessions.client_id, which names the client that first authorized on the row. One browser session serves several applications, so an operator revoking application X after a compromise missed every session X served but did not create. GET and DELETE /sessions accept ?usedClientId=<id> (comma list supported), matching the session's own client_id OR an EXISTS over auth_session_tokens.client_id, which is where per-application attribution lives. Both reaches are needed: the column alone misses later applications, the EXISTS alone misses a session whose token rows have been swept. It is a request parameter rather than a rapiq filter on purpose. Reading intent out of a user-supplied condition tree would have to decide what a negated or OR-nested clientId means, and on a bulk delete a wrong answer is a mass deletion. Its presence selects the admin path on its own, so it carries the same SESSION_DELETE gate and per-session realm match as any target filter, and can never fall through to the self-service branch.
0a42537 to
33e124e
Compare
Problem
Sessions can only be found by
auth_sessions.client_id, and #3400 makes that column write-once, so it names the client that first authorized on the row. One browser session serves several applications, so an operator revoking application X after a compromise misses every session X served but did not create.Concretely, with the admin console opened first and the account console second,
DELETE /sessions?filter[clientId]=<account-console>matches nothing. Before #3400 the column was last-writer-wins, so it matched — differently partial, but partial either way. Neither answers "every session this application served".Change
GETandDELETE /sessionsaccept?usedClientId=<id>, a single id or a comma list. A session matches when eitherclient_idnames one of them (the client that first authorized), orEXISTSoverauth_session_tokens.client_idfinds a token issued for one of them.Both reaches are needed. The column alone misses every later application; the
EXISTSalone misses a session whose token rows have since been swept by the cleanup component.Why a request parameter and not a rapiq filter
Inferring this from a user-supplied condition tree means deciding what a negated or OR-nested
clientIdmeans. On a bulk delete a wrong answer is a mass deletion, so the safe move is a parameter with exactly one meaning. It composes as a mandatory AND-ed bracket next to the existingownerconstraint, so no client-supplied filter can widen it.Its presence selects the admin bulk-revoke path on its own. Without that it would fall through to self-service and silently revoke the caller's own devices instead of the named application's sessions. That means it carries the same
SESSION_DELETEgate and per-session realm match as any target filter — filter breadth still cannot escalate, so arealm_adminreaches only its own realm's sessions.filter[clientId]is untouched and still matches the session column.Verification
check:typesclean, ESLint clean.session-token-attribution.spec.tspins the actual capability gap: with two applications on one browser session,filter[clientId]=<second app>does not return the session,usedClientId=<second app>does, and the revoke removes it.Follow-up left open
The account console's Applications page revokes consent, which is prompt-level: it stops the next silent issue and leaves live tokens working. It could now offer a real "sign out of this application everywhere" by calling this endpoint. Not done here, and note the page lists consent rows, which
authorization/module.ts:57skips forbuiltInclients, so neither console appears there.