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:
@@ -198,12 +198,17 @@ func closeSessions(srv *mcp.Server) {
|
||||
|
||||
// matching lists the entries whose identity includes the subject.
|
||||
func (sp *statelessPath) matching(guard string, userID uint) []*statelessEntry {
|
||||
return sp.matchingFunc(func(id Identity) bool { return id.has(guard, userID) })
|
||||
}
|
||||
|
||||
// matchingFunc lists the entries whose identity satisfies match.
|
||||
func (sp *statelessPath) matchingFunc(match func(Identity) bool) []*statelessEntry {
|
||||
sp.mu.Lock()
|
||||
defer sp.mu.Unlock()
|
||||
var out []*statelessEntry
|
||||
for _, e := range sp.entries {
|
||||
e.mu.Lock()
|
||||
hit := e.identity.has(guard, userID)
|
||||
hit := match(e.identity)
|
||||
e.mu.Unlock()
|
||||
if hit {
|
||||
out = append(out, e)
|
||||
@@ -215,7 +220,13 @@ func (sp *statelessPath) matching(guard string, userID uint) []*statelessEntry {
|
||||
// evict drops the entries of a subject (a revocation or deletion) and
|
||||
// closes their sessions, so a subscriptions/listen stream ends.
|
||||
func (sp *statelessPath) evict(guard string, userID uint) {
|
||||
for _, e := range sp.matching(guard, userID) {
|
||||
sp.evictFunc(func(id Identity) bool { return id.has(guard, userID) })
|
||||
}
|
||||
|
||||
// evictFunc drops the entries whose identity satisfies match and closes
|
||||
// their sessions.
|
||||
func (sp *statelessPath) evictFunc(match func(Identity) bool) {
|
||||
for _, e := range sp.matchingFunc(match) {
|
||||
sp.mu.Lock()
|
||||
if cur, ok := sp.entries[e.binding]; ok && cur == e {
|
||||
sp.order.Remove(e.elem)
|
||||
|
||||
Reference in New Issue
Block a user