When any peer disconnects from a session without closing it, Teleport marks it as active and does not publish the session recordings.
This PR closes the session once every peer disconnects to avoid leaving zombie sessions when a user intentionally blocks traffic or when a VPN disconnects.
It also waits until all events are pushed before closing the recorder.
Fixes#17848Fixes#18194
* Refactor (*TermManager) Read
Removes spawning a goroutine per `Read` and eliminates using a `sync.Cond`
to indicate whether data flow is on/off. Doing so results in a
goroutine **per character** written that lasts for the entire duration
of the session. A large number of sessions, or very long lived sessions
cause the Proxy to consume large amounts of memory.
The mechanism was meant to prevent reading if data flow was not enabled
for a session due to certain constraints of moderated sessions. By replacing
the `sync.Cond` with a `chan` the same effect can be achieved
without needing a goroutine.
Fixes#17666
* Add CSRF mitigations
This commit includes two fixes:
1. Enforce an application/json Content-Type server-side.
2. When checking the bearer token, verify that the user
associated with the token matches the user associated
with the cookie.
* Fix TEL-Q122-13: Access Requests Denial Of Service Via Request Reason (#125) (#127)
* Ignore input when data flow is off in TermManager
When data flow is disabled in TermManager (at the beginning or when TermManager.Off was called) we should ignore all input we receive (currently we buffer it)
* Agent forwarding socket security fix.
Co-authored-by: Lisa Kim <lisa@goteleport.com>
Co-authored-by: Joel <jwejdenstal@icloud.com>
Co-authored-by: Przemko Robakowski <przemko@przemko-robakowski.pl>