Files
pipelines/internal/protocol/elevation.go
T
alan f11ff8650d Require step-up password confirmation for shells, terminals and file changes
A new elevate request verifies the web sign-in password (scrypt hash, read-only,
rate-limited, constant time) and elevates that connection for 15 minutes.
chat_shell_run/input, rename/move/delete, terminal_open/input and POST /files
(via a per-connection upload token) are refused with code elevation_required
until then.
2026-11-10 01:21:15 +00:00

40 lines
1.8 KiB
Go

package protocol
// Step-up re-authentication. A signed-in web session can read everything, but
// running shell commands, typing into a shell, changing or uploading files and
// opening a terminal additionally need a recent password confirmation on the
// same connection. The server verifies the password against the web sign-in
// password file; the elevation lasts for a bounded time (15 minutes by
// default) and ends with the connection.
const (
// Elevate confirms the sign-in password (Message.Password). The reply is
// Elevated, or Error with Code ErrorElevationFailed or
// ErrorElevationUnavailable.
Elevate = "elevate"
// Elevated carries Elevation: when it ends and the upload token.
Elevated = "elevated"
// ErrorElevationRequired types the refusal of a gated request on a
// connection that is not (or no longer) elevated. Clients confirm the
// password with Elevate and retry.
ErrorElevationRequired = "elevation_required"
// ErrorElevationFailed types a wrong password or a rate-limited attempt.
ErrorElevationFailed = "elevation_failed"
// ErrorElevationUnavailable types an elevate on a server without a web
// sign-in password file (nothing is gated there).
ErrorElevationUnavailable = "elevation_unavailable"
// ElevationHeader carries Elevation.Token on POST /files. A refused upload
// answers 403 with a JSON body {"code":"elevation_required","error":...}.
ElevationHeader = "X-Pipelines-Elevation"
)
// Elevation is the elevated reply body.
type Elevation struct {
// ExpiresAt is RFC 3339 UTC; Seconds is the remaining lifetime, for
// clients whose clock differs from the server's.
ExpiresAt string `json:"expires_at"`
Seconds int `json:"seconds"`
// Token authorises HTTP uploads for as long as this connection stays
// elevated. It is random, held only in memory and never logged.
Token string `json:"token,omitempty"`
}