admin-api: allow filtering OAuth2 sessions by multiple clients

Make `filter[client]` on `GET /api/admin/v1/oauth2-sessions` repeatable
so admin tooling can fetch sessions belonging to a set of clients in
one request. The field on `FilterParams` changes from `Option<Ulid>`
to `Vec<Ulid>`; the struct was already extracted with
`axum_extra::extract::Query` so the repeated values are not silently
dropped.

Each client ULID is validated to exist (mirroring the previous
single-client `404` behaviour) before being passed to the new
`OAuth2SessionFilter::for_clients` storage filter. The `Display`
impl used to reconstruct cursor links now emits one
`filter[client]=…` segment per client so pagination preserves the
filter. The OpenAPI schema is regenerated via `misc/update.sh` and
now describes the parameter as an array.
This commit is contained in:
Quentin Gliech
2026-06-01 17:30:14 +02:00
parent 5cb9ca1043
commit ce68d63adb
2 changed files with 142 additions and 34 deletions
+14 -20
View File
@@ -505,7 +505,7 @@
"oauth2-session"
],
"summary": "List OAuth 2.0 sessions",
"description": "Retrieve a list of OAuth 2.0 sessions.\nNote that by default, all sessions, including finished ones are returned, with the oldest first.\nUse the `filter[status]` parameter to filter the sessions by their status and `page[last]` parameter to retrieve the last N sessions.",
"description": "Retrieve a list of OAuth 2.0 sessions.\nNote that by default, all sessions, including finished ones are returned, with the oldest first.\nUse the `filter[status]` parameter to filter the sessions by their status and `page[last]` parameter to retrieve the last N sessions.\nThe `filter[client]` parameter may be repeated to filter on multiple clients at once.",
"operationId": "listOAuth2Sessions",
"parameters": [
{
@@ -609,17 +609,14 @@
{
"in": "query",
"name": "filter[client]",
"description": "Retrieve the items for the given client",
"description": "Retrieve the items for the given client(s)\n\n This parameter may be repeated to filter on multiple clients at\n once (sessions matching any of the given clients are returned).",
"schema": {
"description": "Retrieve the items for the given client",
"anyOf": [
{
"$ref": "#/components/schemas/ULID"
},
{
"type": "null"
}
]
"description": "Retrieve the items for the given client(s)\n\n This parameter may be repeated to filter on multiple clients at\n once (sessions matching any of the given clients are returned).",
"type": "array",
"items": {
"$ref": "#/components/schemas/ULID"
},
"default": []
},
"style": "form"
},
@@ -5412,15 +5409,12 @@
]
},
"filter[client]": {
"description": "Retrieve the items for the given client",
"anyOf": [
{
"$ref": "#/components/schemas/ULID"
},
{
"type": "null"
}
]
"description": "Retrieve the items for the given client(s)\n\n This parameter may be repeated to filter on multiple clients at\n once (sessions matching any of the given clients are returned).",
"type": "array",
"items": {
"$ref": "#/components/schemas/ULID"
},
"default": []
},
"filter[client-kind]": {
"description": "Retrieve the items only for a specific client kind",