1ad85de1f1
The proxy forwards an HMAC-derived session id (X-Pipelines-Session) on /connect and POST /files; the server trusts it only on token-authenticated requests and keys elevation by it, so reconnects stay elevated up to a 24 h cap. Terminals rely on their su -l login. The app no longer forgets the elevation on disconnect and asks again only on a fresh refusal.
48 lines
2.4 KiB
Go
48 lines
2.4 KiB
Go
package protocol
|
|
|
|
// Step-up re-authentication. A signed-in web session can read everything, but
|
|
// running shell commands, typing into a shell and changing or uploading files
|
|
// additionally need a password confirmation. (Terminals are not gated: each
|
|
// one asks for the OS account password through `su -l`.) The server verifies
|
|
// the password against the web sign-in password file. A confirmation belongs
|
|
// to the web session the proxy reports (SessionHeader): every connection of
|
|
// that session stays elevated until the session ends or a long cap (24 hours
|
|
// by default) passes. A connection without a trusted session id elevates only
|
|
// itself, until it closes.
|
|
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"
|
|
// SessionHeader carries the web proxy's opaque id of the signed-in web
|
|
// session on /connect upgrades and POST /files: an HMAC of the session
|
|
// token's generation and id, never the cookie. The server trusts it only
|
|
// on a request authenticated with the shared server token.
|
|
SessionHeader = "X-Pipelines-Session"
|
|
)
|
|
|
|
// 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 elevation lasts. It
|
|
// is random, held only in memory and never logged.
|
|
Token string `json:"token,omitempty"`
|
|
}
|