You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 0bed2ac
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-auth): #30918 stamp only the consent that admitted the MCP call
Since #30879, verifyMcpAccessToken admits a token only while its consent
stands: the consent for (azp, sub, organization) exists and was created no
later than the token's iat (mcpConsentAdmits). The stamp now picks its
consent by that same rule, so it can only land on the consent that admitted
the call.
- A revoked consent refuses the call, so nothing is stamped.
- After a re-grant, a token of the earlier grant is refused. The new consent
is not stamped with the old token's use even when the re-grant lands
between the verdict and the after-response stamp, because it is newer than
the token.
AuthManager hands the stamp the verified token's iat (decoded from the token
the verifier has just admitted). The stamp's consent read also selects
created_at.
The real-engine tests mint tokens with the iat the provider mints. A
client_id-only token is now refused by the verifier. Two new cases cover the
composition: revoke, then re-grant; and the re-grant race on the real engine.
Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4d1LNDAUs8pz7DNjQFC
Copy file name to clipboardExpand all lines: .changeset/30918-plugin-auth-authorized-clients.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,4 +14,4 @@ Two new reads, both ObjectStack mounts ahead of the better-auth catch-all and bo
14
14
15
15
Each row carries exactly `id` (the consent id, the key `POST /oauth2/delete-consent` takes), `clientId`, `name`, `scopes`, `organizationId`, `authorizedAt` and `lastUsedAt`. Nothing in it identifies or reconstructs a token. The answer is newest first, at most 200 rows, with `truncated: true` when the person holds more, and it is sent with `Cache-Control: no-store`.
16
16
17
-
`lastUsedAt` is the start of the most recent clock hour in which the client made a verified MCP call under that consent, or `null` when none has been recorded. The server writes it after `verifyMcpAccessToken` admits a token with an `azp` client: off the request path, at most once per consent per hour in each process (several processes may each write the same hour start), from the verified token and the server clock alone. A store failure never fails the MCP call, and each distinct failure is logged once per process at `error`; a consent withdrawn between the stamp's read and its write is not a failure. It lands in the new `sys_oauth_consent.last_used_at` column, so a deployment picks it up at its next schema sync. Until then the reads answer `500` and the stamp logs that error once per process.
17
+
`lastUsedAt` is the start of the most recent clock hour in which the client made a verified MCP call under that consent, or `null` when none has been recorded. The server writes it after `verifyMcpAccessToken` admits a token, and only on the consent that admitted it: the consent for the token's client, person and organization, created no later than the token was issued, the rule the verifier's own consent read applies. So a revoked consent, or a token of an earlier grant, stamps nothing. The write is off the request path, at most once per consent per hour in each process (several processes may each write the same hour start), from the verified token and the server clock alone. A store failure never fails the MCP call, and each distinct failure is logged once per process at `error`; a consent withdrawn between the stamp's read and its write is not a failure. It lands in the new `sys_oauth_consent.last_used_at` column, so a deployment picks it up at its next schema sync. Until then the reads answer `500` and the stamp logs that error once per process.
0 commit comments