fix(pier): end only the revoked token's or client's MCP sessions and log the client address (B-WR-04, B-IN-04)

- pact.MCPSubjectChanged and pier.Event gain TokenID and ClientID; a
  narrowed revoked event closes only matching sessions and stateless servers
- cabana fires the admin token revoke with the token row id
- towel.WithClientIP/ClientIP; pier puts the address (surf applies
  http.trusted_proxies) on the resolve context and ResolveBackendToken logs it
This commit is contained in:
Jakub Zych
2026-10-23 16:21:37 +02:00
parent 0ec00f7f69
commit 24cf6cd931
16 changed files with 158 additions and 31 deletions

View File

@@ -272,10 +272,19 @@ type LinkedBackendUser struct {
// deactivated (MCPSubjectDeleted). The MCP module re-lists the subject's
// tools or ends its sessions; every call re-checks anyway, so a missed event
// only leaves a stale list for longer.
//
// TokenID and ClientID narrow an MCPSubjectRevoked event. A non-zero TokenID
// ends only the sessions whose subject under Guard is UserID with that
// TokenID and no ClientID: the sessions one personal token opened. A
// non-empty ClientID ends only the sessions whose subject under Guard is
// UserID with that ClientID: one OAuth client's grant. With neither, every
// session of the subject ends. Other kinds ignore both fields.
type MCPSubjectChanged struct {
Guard string
UserID uint
Kind string
Guard string
UserID uint
Kind string
TokenID uint
ClientID string
}
// Kinds of MCPSubjectChanged.