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.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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"`
|
||||
}
|
||||
@@ -302,6 +302,12 @@ type Message struct {
|
||||
MovePath *MovePathRequest `json:"move_path,omitempty"`
|
||||
DeletePath *DeletePathRequest `json:"delete_path,omitempty"`
|
||||
PathMutated *PathMutatedResult `json:"path_mutated,omitempty"`
|
||||
// Step-up re-authentication (see elevation.go): Code types an error,
|
||||
// Password is the elevate body (never logged or echoed) and Elevation the
|
||||
// elevated reply.
|
||||
Code string `json:"code,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Elevation *Elevation `json:"elevation,omitempty"`
|
||||
// ChatAttachmentImageRequest is the chat_attachment_image body and
|
||||
// ChatAttachmentImage its reply.
|
||||
ChatAttachmentImageRequest *ChatAttachmentImageRequest `json:"chat_attachment_image_request,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user