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
feat(pam): support terminating active sessions (#167)
* feat: support killing active PAM sessions via gateway session registry
Add a session registry to the gateway so that ALPN cancellation signals
can find and close active proxy connections. When an admin terminates a
session from the UI, the gateway now kills the proxy immediately instead
of waiting for expiry.
- Add pamSessions registry (map + mutex) to Gateway struct
- Register/deregister sessions around HandlePAMProxy dispatch
- HandlePAMCancellation now calls cancelSession to close the proxy conn
- Per-session context so expiry timer exits cleanly on cancellation
- HandleGatewayDisconnect on BaseProxyServer to exit the CLI proxy
cleanly when the backend connection drops
* fix: track multiple connections per session in gateway PAM registry
The registry previously stored a single entry per session ID, so each
new client connection (e.g., multiple psql windows) overwrote the
previous one. On termination, only the last connection was killed.
Change the registry to a slice per session ID so CancelPAMSession
closes all active connections for the session.
* fix: only trigger proxy shutdown on actual gateway errors
HandleGatewayDisconnect was called unconditionally when errCh received
a value, but io.Copy returns nil on clean EOF (normal client disconnect).
This caused the entire proxy to shut down when a user simply exited psql.
Only call HandleGatewayDisconnect when err != nil, so normal client
disconnects don't kill the proxy.
Also remove redundant shutdownCh select guard before shutdownOnce.Do
since sync.Once already provides the once-only guarantee.
* fix: distinguish gateway disconnect from normal client disconnect
Split the shared errCh into separate gatewayErrCh and clientErrCh so we
can detect which side closed the connection first. Only call
HandleGatewayDisconnect when the gateway side drops — not when the
client (e.g., psql) exits normally.
Previously, HandleGatewayDisconnect was called unconditionally on any
errCh value, which shut down the entire proxy when a user simply exited
their client. With the err != nil guard, it was never called because
both normal and admin-terminated closes produce nil from io.Copy.
Also remove redundant shutdownCh select guard in HandleGatewayDisconnect
since sync.Once already provides the once-only guarantee.
* refactor: extract disconnect channel logic into base proxy helpers
0 commit comments