Repository navigation
fix(authserver): a suspended, revoked or locked client gets no token, authorization or active introspection (#345) - #350
Conversation
… authorization or active introspection; the status update works on PostgreSQL (#345) - ClientStatusService: active = client_status active (NULL is the default) and no running lock; read on every request. - ClientStatusEnforcement: client authentication fails with invalid_client (token, introspection, revocation); introspection reports the client's tokens inactive; /oauth2/authorize answers as for an unknown client_id, with no redirect. /authorize/delegate and the AS's own bearer-token check refuse an inactive client too. - PostgreSQL: the status update casts to client_status_type (it was 500). - H2 V12 adds client_status, locked_until and updated_by. - Tests on MySQL and PostgreSQL through the real status endpoint; docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ended during delegation gets no access_denied redirect (#345 review) - ClientStatusService: a suspended client whose locked_until has passed counts as active, so lock_duration_minutes ends the suspension; without a lock it lasts until reactivation; revoked never ends on its own. - AuthorizeContinueController: a client no longer active when the customer comes back from the DC gets 400 on allow and deny (no code, no access_denied redirect). - AuthorizationServerConfig: the validator comment says Spring checks the grant type before the client's status. - Docs: what lock_duration_minutes does. - Tests: ClientStatusServiceTest rows for timed suspensions and revocations; a timed suspension through the status endpoint on MySQL and PostgreSQL; the continue controller's inactive-client paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 1, finding 2, the consent part (Spring's consent POST could mint a code for a client suspended mid-flow): this can't happen, so no change. Since #305, the AS keeps no customer sign-in and no stored consent. The deny part of the finding (an |
…cked_until; a timed suspension is audited; certificate validation uses the same status rule (#345 review) - ClientStatusService.statusInForce, and the same rule as SQL (STATUS_IN_FORCE_SQL): a timed suspension whose lock has passed is active, an active client with a running lock is suspended, revoked stays revoked. - Client details and the list report the status in force and locked_until; the list's status filter uses the same rule (and so works on PostgreSQL). - The status change audit holds lock_duration_minutes and locked_until. - lock_duration_minutes with active or revoked is 400, not dropped. - ClientCertificateService asks ClientStatusService whether a client is active. - ClientStatusService Javadoc and the API doc match the rule. - Tests: the status in force in Java and SQL on H2; client details and the list through a timed suspension on MySQL and PostgreSQL; the audit and the 400; certificate validation follows ClientStatusService. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d suspension; client management uses enforcement's clock (#345 review) - A timed suspension is stored as active with locked_until; a stored suspended or revoked never ends on its own, whatever writes locked_until. - Any other stored status is revoked in Java as in the list's SQL. - Client details read locked_until with getTimestamp, as the list does. - The list, details and status update use ClientStatusService's clock; a lock is set in whole seconds, so the audit records the time stored. - A status read failure during certificate validation is logged as a warning with its exception. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…til is reported only while it decides the status (#345 review) - The list's status filter takes only active, suspended or revoked (400 otherwise), so the result no longer depends on the database's collation. - Client details and the list report locked_until only while it runs on a client stored active (ClientStatusService.lockInForce), so a suspended client without it is open-ended. - The Javadoc and doc say a status change replaces the earlier state; only other writers of locked_until are limited to extending a lock. - Stale descriptions of an active client with a lock corrected; the stored-row check fails when the row is missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 4, finding 1 (rows stored as
|
… statuses are tested against the status update's (#345 review) - A blank status filter is 400; an empty one still means no filter. - A test checks STATUSES accepts exactly what the status update's @pattern does. - The timed-suspension stored-row check asserts the lock is present before reading it. - The Javadoc and doc say a lock is reported on a client stored active or NULL, and a stored suspended lasts until the client is set active. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… filter's statuses must equal the status update's pattern (#345 review) - The blank-status cases send " ", a tab and two spaces with param(), since MockMvc re-encodes a '%' in the URI; they fail with the old hasText guard. - The test compares the @pattern with STATUSES exactly, so a status added to only one of them fails. - Rewrapped the lockedUntil Javadoc and the API doc paragraph. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…age must name every status (#345 review) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 8 (
🤖 Generated with Claude Code |
Closes #345. Part 2 of #344 (plan); part 1 was #346.
Suspending, revoking or locking a client through
PUT /api/v1/oauth2/clients/{clientId}/statusnow takes effect. Before, the status was stored and nothing read it, and on PostgreSQL it was not even stored.Changes
ClientStatusServicedecides whether a client may use the AS now:client_statusisactive(a NULL means the column default,active) and itslocked_until, if set, has passed;suspendedorrevokedlasts until the client is set active. A lock only ever restricts (round 3): it suspends anactiveclient while it runs and never ends a stored status. So a suspension withlock_duration_minutesis stored asactivewithlocked_until, and ends on its own when the lock does. Whatever writeslocked_until(the database, or a future lockout, fix(authserver): max-failures-before-lock and default-lock-duration-minutes are documented but never applied #353), it can't let a client in;revoked; a client with no row is not active.It reads the database on every call, so a suspension, a reactivation or the end of a lock applies to the next request. A database error is not caught: the request fails rather than letting the client in.
ClientStatusEnforcementapplies it through Spring Authorization Server's own hooks:/oauth2/token,/oauth2/introspect,/oauth2/revokeinvalid_client, as for a wrong secret, with no description, so nothing says the secret was right. No new token, refresh orclient_credentialstoken./oauth2/introspectactive: false, so the DC releases no data. The tokens are kept: on reactivation they work again until they expire./oauth2/authorizeclient_id, with no redirect to the client (RFC 6749 4.1.2.1). It runs before the redirect URI and scope checks (Spring checks the grant type first), and again on the replay that would mint the code./authorize/delegatecan be reached without going through/oauth2/authorize. It now refuses an unknown or inactive client with 400 before the customer is sent to the DC./oauth2/authorize/continuedoes the same when the customer comes back: a client suspended while the customer was at the DC gets neither a code nor anaccess_deniedredirect.The AS's own bearer-token check (
AuthorizationServiceOpaqueTokenIntrospector, used by the admin API, actuator and/oauth2/register) refuses a token of an inactive client, as/oauth2/introspectdoes.Pre-existing: on PostgreSQL the status update always answered 500.
client_statusis the enum typeclient_status_type, which refuses a text parameter. The update now casts to it there (CAST(? AS client_status_type)), with the database read once at startup, as for the audit JSON (fix(authserver): client management API: list always 500, status without reason 500s after applying, bulk logs raw ids, null scope saved; fix or retire the controller #344 review).H2: the new migration
V12__client_status_columnsaddsclient_status(with the same three values),locked_untilandupdated_by. H2 skipped V2 (Complete #123 schema-repair sync: align AS V1 schema with application code column names #145), so the status update failed there, and so would the new check.revokedandsuspendedact the same. Ending a client's tokens for good is a client delete (#346), or #349 once fixed.Docs:
OAUTH2_CLIENT_MANAGEMENT_API.mdsays what each status does.Not covered
securityLevelfilter, and create and update'sclient_status/security_level: fix(authserver): client management create, update and list filters fail on PostgreSQL's enum columns; H2 create writes missing columns #351, with fix(authserver): client management API: list always 500, status without reason 500s after applying, bulk logs raw ids, null scope saved; fix or retire the controller #344 part 3. (Thestatusfilter now works there: it compares the status in force, which is text.)prodanddev-mysqlstop the MySQL migrations before V7, V9 and V11: fix(authserver): prod and dev-mysql Flyway targets skip MySQL V7, V9 and V11 #352.Tests
ClientSuspensionScenarios, run on MySQL (ClientSuspensionMySqlIntegrationTest) and PostgreSQL (ClientSuspensionPostgreSqlIntegrationTest), 8 each. The status is changed through the real status endpoint as an administrator:invalid_clientwith no description; reactivated: a token again;lock_duration_minutesthrough the endpoint: stored asactivewith a lock in whole seconds; no token until the lock ends, then a token; client details and the list'sstatusfilter reportsuspended, thenactive;suspended, with nolocked_until;active: falsewithout its claims, and active again after reactivation;/oauth2/authorizeand/authorize/delegateare 400 with no redirect; when active the same request is delegated to the DC.ClientStatusServiceTest(28, against the real H2 migrations, including V12): each status and lock combination by id, byclient_id, and as the status in force in Java and in the list's SQL; a lock written onto a stored suspension doesn't end it; any other stored value isrevokedin Java and SQL;now()is the service's clock;lockInForcereports a lock only while it decides the status; an unknown or null client, H2 refusing an unknown status, and the PostgreSQL cast.AuthorizationServiceOpaqueTokenIntrospectorTest(2): the AS's own bearer-token check accepts an active client's token and refuses an inactive one's.AuthorizeDelegateControllerTest: an inactive client is refused and no handoff is built.ClientCertificateServiceStatusTest: certificate validation followsClientStatusService, and a database error refuses the client and is logged as a warning with its exception.OAuth2ClientManagementControllerTest(with a fixedClientStatusServiceclock): the list filters by the status in force at the clock's time for the page and the count; a timed suspension is written asactivewith the lock in whole seconds, and its audit holds the status asked for, its length and that end;lock_duration_minuteswithactiveorrevokedis 400; the list'sstatusfilter refusespaused,Suspendedand a blank value with 400 before any query (the blank cases fail with the old check), and its statuses must equal the status update's@Patternexactly, whose message must name each of them.AuthorizeContinueControllerTest: a client that became inactive during the delegation gets 400 on allow (no grant context kept) and on deny (noaccess_deniedredirect).Code review
Security-sensitive (it decides whether a client gets tokens and whether customer data is released).
Round 1,
/code-review high(whole PR):lock_duration_minutesdid nothing: the endpoint writes a lock only withsuspended, and any status other thanactivewas refused, so a timed suspension never ended (and the doc said it did)ClientStatusServiceTestrows, a scenario through the endpoint on MySQL and PostgreSQL, doc correctedaccess_deniedredirect on deny; the review also suspected Spring's consent POST could mint a code/oauth2/authorize/continuechecks the status, 400); consent POST answered on the PR: unreachable since #305Fixes in 91a65c9. Round 1 found a real bug in this PR's own changes, so round 2 is a scoped
/code-review xhighof that commit.Round 2,
/code-review xhigh(scoped to 91a65c9):statusfilter still reportedsuspended, andlocked_untilwas shown nowhereClientStatusService.statusInForce(and the same rule as SQL for the filter) is what client details and the list report, withlocked_until; tested on MySQL and PostgreSQLlock_duration_minutesandlocked_untilare in the audit dataactiveand ignored the lockClientCertificateServiceasksClientStatusServicelock_duration_minuteswithactiveorrevokedwas answered 200 and droppedmax-failures-before-lock/default-lock-duration-minutesdocumented, read nowhereactivelets a client inactiveclient with a running lock is refusedRound 2 found real problems in this PR's own changes (1, 2); fixes in 1933d8b; the owner chose a scoped
xhigh(notultra) for round 3. Under the review rules, if round 3 still finds a real bug, the automated reviews stop and the owner reviews the design.Round 3,
/code-review xhigh(scoped to 1933d8b):activewithlocked_until; a storedsuspendedorrevokednever ends on its own. Regression tests inClientStatusServiceTestand on MySQL and PostgreSQL; doc updated; the constraint for a lockout (extend only, never shorten) is noted on #353locked_untiltype its switch didn't listgetTimestamp, as the list doesactive/suspended, the SQL saidrevokedbut Java returned the valuerevoked; tested against the SQLClientStatusService'sClientStatusService.now()locked_untilis null when there is none; it's left outlocked_untilkept fractions of a second that MySQL doesn't storeFixes in 45f1972. Fixing #1 treats it as a real bug in this PR's own changes, so round 4 goes up, not down; the owner chose a scoped
xhigh(notultra).Round 4,
/code-review xhigh(scoped to 45f1972):suspendedwith a lock before this change would stay suspended for goodmainnever enforced the status); it fails closedstatusfilter wasn't validated:pausedgave an empty page, andSuspendedmatched on MySQL onlyactive,suspended,revokedrevokedclient ends when its lock does, which contradicted the Javadoc's "nothing that writeslocked_untilcan let a client in"activedoes; only other writers are limited to extending a locklocked_untilwas reported even when it didn't decide the status, so an open-ended suspension looked as if it would endactive(ClientStatusService.lockInForce)queryForObject, which fails thenFixes in 8d2ca29. Round 4 found no real bug in this PR's own changes once #1 is answered (#2 is pre-existing, the rest are nits), so round 5 steps down to a scoped
high, the floor for security-sensitive code.Round 5,
/code-review high(scoped to 8d2ca29):statusfilter was ignored while other unknown values got 400@Patterncould drift apartactive, but NULL counts toosuspendedends with its lockFixes in fc8c290: nits only, touching no enforcement code, so round 6 is a scoped
medium.Round 6,
/code-review medium(scoped to fc8c290):status=%20case sent the literal text%20(MockMvc re-encodes%), so the new blank-status check was untestedparam(); confirmed the cases fail with the old check@Patterntest checked a fixed list, so a status added only to the pattern passed^(+ the joinedSTATUSES+)$Fixes in 0901cc5 (tests and wording only), so round 7 is a scoped
medium, the floor for a test change.Round 7,
/code-review medium(scoped to 0901cc5):"\t"@Patternmessage lists the statuses by hand and wasn't checkedSTATUSESFixes in 80f6217 (tests only), so round 8 is a scoped
medium.Round 8,
/code-review medium(scoped to 80f6217):containsmatches substrings, so a new status that is a prefix of an existing one would pass"\t"No
src/change followed round 8, so the review cycle is complete.🤖 Generated with Claude Code