Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyProvisionPatches(bp *models.Blueprint, patches []ProvisionPatch) (*models.Blueprint, error)
- func ScopeAllows(scopes []string, action string) bool
- func ValidateScope(s string) error
- func ValidateScopes(scopes []string) error
- type BlueprintsObligation
- type EvalRequest
- type ExpiresInObligation
- type JWTIssuer
- type JWTIssuerConfig
- type JWTVerifier
- type JWTVerifierConfig
- type PolicyInput
- type PolicyResource
- type PolicyResult
- type ProvisionPatch
- type RecordObligation
- type RolesObligation
- type SSHAction
- type SSHContext
- type SSHEvalRequest
- func (r *SSHEvalRequest) Build() (*SSHEvalRequest, error)
- func (r *SSHEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SSHEvalRequest) Validate() error
- func (r *SSHEvalRequest) WithAsUser(user string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithBlueprint(blueprint string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithCommand(cmd string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithHost(host string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithOwner(owner string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithPTY(pty bool) *SSHEvalRequest
- func (r *SSHEvalRequest) WithPort(port string) *SSHEvalRequest
- func (r *SSHEvalRequest) WithSocketPath(path string) *SSHEvalRequest
- type Scope
- type ScopesObligation
- type SessionAction
- type SessionContext
- type SessionListEvalRequest
- func (r *SessionListEvalRequest) Build() (*SessionListEvalRequest, error)
- func (r *SessionListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SessionListEvalRequest) Validate() error
- func (r *SessionListEvalRequest) WithOwner(owner string) *SessionListEvalRequest
- func (r *SessionListEvalRequest) WithWorkspace(workspaceID string) *SessionListEvalRequest
- type SessionSource
- type SessionStartEvalRequest
- func (r *SessionStartEvalRequest) Build() (*SessionStartEvalRequest, error)
- func (r *SessionStartEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SessionStartEvalRequest) Validate() error
- func (r *SessionStartEvalRequest) WithBlueprint(blueprint string) *SessionStartEvalRequest
- func (r *SessionStartEvalRequest) WithOwner(owner string) *SessionStartEvalRequest
- func (r *SessionStartEvalRequest) WithSource(source SessionSource) *SessionStartEvalRequest
- type SessionType
- type SudoObligation
- type TokenCreateContext
- type TokenCreateSource
- type UserAuthContext
- type UserAuthEvalRequest
- func (r *UserAuthEvalRequest) Build() (*UserAuthEvalRequest, error)
- func (r *UserAuthEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *UserAuthEvalRequest) Validate() error
- func (r *UserAuthEvalRequest) WithAuthMethod(method UserAuthMethod) *UserAuthEvalRequest
- func (r *UserAuthEvalRequest) WithFingerprint(fp string) *UserAuthEvalRequest
- func (r *UserAuthEvalRequest) WithIDP(idp string) *UserAuthEvalRequest
- func (r *UserAuthEvalRequest) WithOrg(org string) *UserAuthEvalRequest
- type UserAuthMethod
- type UserClaims
- type UserDataType
- type UserListEvalRequest
- type UserOnboardEvalRequest
- func (r *UserOnboardEvalRequest) Build() (*UserOnboardEvalRequest, error)
- func (r *UserOnboardEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *UserOnboardEvalRequest) Validate() error
- func (r *UserOnboardEvalRequest) WithIDP(idp string) *UserOnboardEvalRequest
- func (r *UserOnboardEvalRequest) WithOrg(org string) *UserOnboardEvalRequest
- type UserReadEvalRequest
- type UserResource
- type UserTokenCreateEvalRequest
- func (r *UserTokenCreateEvalRequest) Build() (*UserTokenCreateEvalRequest, error)
- func (r *UserTokenCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *UserTokenCreateEvalRequest) Validate() error
- func (r *UserTokenCreateEvalRequest) WithSource(source TokenCreateSource) *UserTokenCreateEvalRequest
- type UserTokenReadEvalRequest
- type UserWriteEvalRequest
- type WorkspaceAccessEvalRequest
- func (r *WorkspaceAccessEvalRequest) Build() (*WorkspaceAccessEvalRequest, error)
- func (r *WorkspaceAccessEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceAccessEvalRequest) Validate() error
- func (r *WorkspaceAccessEvalRequest) WithOwner(owner string) *WorkspaceAccessEvalRequest
- type WorkspaceAction
- type WorkspaceAppEvalRequest
- func (r *WorkspaceAppEvalRequest) Build() (*WorkspaceAppEvalRequest, error)
- func (r *WorkspaceAppEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceAppEvalRequest) Validate() error
- func (r *WorkspaceAppEvalRequest) WithOp(op WorkspaceAppOp) *WorkspaceAppEvalRequest
- func (r *WorkspaceAppEvalRequest) WithOwner(owner string) *WorkspaceAppEvalRequest
- type WorkspaceAppOp
- type WorkspaceConnectContext
- type WorkspaceConnectEvalRequest
- func (r *WorkspaceConnectEvalRequest) Build() (*WorkspaceConnectEvalRequest, error)
- func (r *WorkspaceConnectEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceConnectEvalRequest) Validate() error
- func (r *WorkspaceConnectEvalRequest) WithOwner(owner string) *WorkspaceConnectEvalRequest
- func (r *WorkspaceConnectEvalRequest) WithPort(port string) *WorkspaceConnectEvalRequest
- func (r *WorkspaceConnectEvalRequest) WithType(t WorkspaceConnectType) *WorkspaceConnectEvalRequest
- type WorkspaceConnectType
- type WorkspaceEvalRequest
- func (r *WorkspaceEvalRequest) Build() (*WorkspaceEvalRequest, error)
- func (r *WorkspaceEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceEvalRequest) Validate() error
- func (r *WorkspaceEvalRequest) WithBlueprint(bp *models.Blueprint) *WorkspaceEvalRequest
- func (r *WorkspaceEvalRequest) WithBlueprintName(name string) *WorkspaceEvalRequest
- func (r *WorkspaceEvalRequest) WithMode(mode WorkspaceProvisionMode) *WorkspaceEvalRequest
- func (r *WorkspaceEvalRequest) WithOwner(owner string) *WorkspaceEvalRequest
- func (r *WorkspaceEvalRequest) WithWorkload(name, namespace, kind string) *WorkspaceEvalRequest
- type WorkspaceFilesEvalRequest
- func (r *WorkspaceFilesEvalRequest) Build() (*WorkspaceFilesEvalRequest, error)
- func (r *WorkspaceFilesEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceFilesEvalRequest) Validate() error
- func (r *WorkspaceFilesEvalRequest) WithOp(op WorkspaceFilesOp) *WorkspaceFilesEvalRequest
- func (r *WorkspaceFilesEvalRequest) WithOwner(owner string) *WorkspaceFilesEvalRequest
- type WorkspaceFilesOp
- type WorkspaceOwnerEvalRequest
- type WorkspaceProvisionContext
- type WorkspaceProvisionMode
- type WorkspaceResource
Constants ¶
const ( // ObligationKeyRecord is the key the policy engine writes when expressing a // session recording obligation. The enforcer reads this key and activates // the appropriate recording backends before the session begins. ObligationKeyRecord = "record" // ObligationRecordNone explicitly disables all session recording. ObligationRecordNone = "none" // Recording channel name tokens used as comma-separated values of the // "record" obligation key. ObligationRecordShell = "shell" ObligationRecordExec = "exec" ObligationRecordDirectTCPIP = "direct-tcpip" ObligationRecordSFTP = "sftp" )
const ( // ObligationKeyScopes is the key the policy engine writes to restrict the // scopes a newly created token may carry. The value is a JSON-encoded array // of scope strings (e.g. ["token:read","workspace:start"]). ObligationKeyScopes = "scopes" // ObligationKeyExpiresIn is the key the policy engine writes to cap a // token's lifetime. The value is a Go duration string (e.g. "720h") or the // literal "never" to permit a non-expiring token. ObligationKeyExpiresIn = "expires_in" // ObligationExpiresInNever is the sentinel value meaning no expiry. ObligationExpiresInNever = "never" )
const ( // ObligationKeySudo is the key the policy engine writes when expressing a // sudo obligation. The enforcer reads this key and applies the value to the // user record before completing onboarding. ObligationKeySudo = "sudo" // ObligationSudoTrue is the obligation value that grants sudo access. ObligationSudoTrue = "true" // ObligationSudoFalse is the obligation value that explicitly denies sudo access. ObligationSudoFalse = "false" )
const ( // ObligationKeyBlueprints is the key the policy engine writes to assign // allowed blueprints during onboarding. The value is a comma-separated // list of blueprint names; "*" grants access to all blueprints. ObligationKeyBlueprints = "blueprints" )
const ( // ObligationKeyPatchPrefix is the prefix the policy engine uses to express // blueprint patch obligations for workspace:provision. Each key of the form // "patch:<json-pointer>" (RFC 6901) names a location in the blueprint YAML // document; the corresponding value is the string to set at that path. // Example: "patch:/resources/cpu" → "2000m". ObligationKeyPatchPrefix = "patch:" )
const ( // ObligationKeyRoles is the key the policy engine writes to assign roles // during onboarding. The value is a JSON-encoded array of role name strings. ObligationKeyRoles = "roles" )
Variables ¶
var ( // ErrTokenExpired is returned when the token's expiry time has passed. ErrTokenExpired = errors.New("jwt: token has expired") // ErrTokenInvalidSignature is returned when the token signature does not // match the expected signing key. ErrTokenInvalidSignature = errors.New("jwt: token signature is invalid") // ErrTokenMalformed is returned when the token string is not a valid JWT. ErrTokenMalformed = errors.New("jwt: token is malformed") )
Sentinel errors returned by JWTVerifier.VerifyToken. Use errors.Is to distinguish failure reasons.
Functions ¶
func ApplyProvisionPatches ¶
func ApplyProvisionPatches(bp *models.Blueprint, patches []ProvisionPatch) (*models.Blueprint, error)
ApplyProvisionPatches applies a slice of ProvisionPatch obligations to a Blueprint and returns the modified copy. The blueprint is round-tripped through YAML so that path tokens match yaml struct tag names. Each patch value is YAML-decoded before being written, so "false" becomes bool(false), "2000m" stays as a string, etc. Returns the original pointer unchanged when patches is empty.
func ScopeAllows ¶
ScopeAllows reports whether any scope in the list permits action. Matching rules (strict):
- "*" matches any action
- "prefix:*" matches any action that starts with "prefix:"
- an exact scope matches only when scope == action
func ValidateScope ¶
ValidateScope reports whether s is a well-formed, recognized scope string. A scope is valid when it is:
- the bare wildcard "*"
- a known exact action string from the registry
- a known wildcard prefix followed by ":*"
func ValidateScopes ¶
ValidateScopes validates every scope in the slice. Returns the first error encountered, or nil when all scopes are valid. At least one scope is required.
Types ¶
type BlueprintsObligation ¶
type BlueprintsObligation struct {
// Blueprints is the list of blueprint names the policy assigns to the user.
// An entry of "*" grants access to all blueprints.
Blueprints []string
}
BlueprintsObligation is the typed representation of the "blueprints" obligation key returned by the policy engine in a PolicyResult for user:onboard.
func ParseBlueprintsObligation ¶
func ParseBlueprintsObligation(obligations map[string]string) (BlueprintsObligation, bool)
ParseBlueprintsObligation reads the "blueprints" key from the obligations map. The value is a JSON-encoded array of blueprint name strings (e.g. ["bp1","bp2"]). Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set a blueprints obligation — in that case the enforcer should preserve its existing default rather than overwriting it.
type EvalRequest ¶
type EvalRequest interface {
// Validate checks the request against its domain contract. It is called
// automatically by Build and FromProto, but can be called explicitly if
// the struct was mutated after construction.
Validate() error
// ToProto serializes the typed request into a gRPC EvaluateRequest,
// attaching the supplied JWT token. Use this on the client side to
// produce the wire message from the typed, validated struct.
ToProto(token string) *authzv1.EvaluateRequest
}
EvalRequest is the common interface for every typed policy evaluation request. Each policy domain (ssh, blueprint, ...) provides a concrete implementation.
On the client side, build the concrete type with its With* builder and call ToProto to produce the gRPC message. On the server side, convert the incoming gRPC message with the domain's FromProto function, which validates the contract and returns the typed struct.
type ExpiresInObligation ¶
type ExpiresInObligation struct {
// Duration is the maximum lifetime of the token. A nil value means the
// policy permits a non-expiring token (ObligationExpiresInNever).
Duration *time.Duration
}
ExpiresInObligation is the typed representation of the "expires_in" obligation key returned by the policy engine in a PolicyResult for token:create.
func ParseExpiresInObligation ¶
func ParseExpiresInObligation(obligations map[string]string) (ExpiresInObligation, bool)
ParseExpiresInObligation reads the "expires_in" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set an expires_in obligation. The sentinel "never" yields an obligation with a nil Duration.
type JWTIssuer ¶
type JWTIssuer struct {
// contains filtered or unexported fields
}
JWTIssuer creates and signs JWT tokens for authenticated users.
func NewJWTIssuer ¶
func NewJWTIssuer(cfg JWTIssuerConfig) (*JWTIssuer, error)
NewJWTIssuer constructs a JWTIssuer from the provided configuration. Returns an error when the configuration is invalid or keying material cannot be loaded.
func (*JWTIssuer) IssueToken ¶
IssueToken creates a signed JWT string for the given user. The token includes both standard registered claims and k8Shell-specific user attributes as additional claims.
type JWTIssuerConfig ¶
type JWTIssuerConfig struct {
// Enabled toggles JWT issuance. When false, the issuer is not initialized.
Enabled bool `yaml:"enabled"`
// Issuer is the value placed in the "iss" claim.
Issuer string `yaml:"issuer"`
// Audience is the value placed in the "aud" claim.
Audience string `yaml:"audience"`
// Expiry is the token lifetime (e.g. "1h", "8h", "24h").
// Defaults to 1 hour when unset.
Expiry time.Duration `yaml:"expiry"`
// SigningMethod selects the signing algorithm. Supported values:
// hs256 (default) – HMAC-SHA-256, requires SecretKey
// rs256 – RSA-SHA-256, requires PrivateKeyFile
// es256 – ECDSA-P256, requires PrivateKeyFile
SigningMethod string `yaml:"signingMethod"`
// SecretKey is the HMAC signing secret (used with hs256).
SecretKey string `yaml:"secretKey"`
// PrivateKeyFile is the path to a PEM-encoded RSA or ECDSA private key
// (used with rs256 / es256).
PrivateKeyFile string `yaml:"privateKeyFile"`
}
JWTIssuerConfig contains configuration for JWT token issuance.
type JWTVerifier ¶
type JWTVerifier struct {
// contains filtered or unexported fields
}
JWTVerifier validates JWT tokens, checking both signature integrity and expiration. It can be used independently from JWTIssuer.
func NewJWTVerifier ¶
func NewJWTVerifier(cfg JWTVerifierConfig) (*JWTVerifier, error)
NewJWTVerifier constructs a JWTVerifier from the provided configuration.
For hs256 SecretKey is used for verification. For rs256 / es256 the verification key is resolved in this order:
- PublicKeyFile (if set)
- Public key extracted from PrivateKeyFile
func (*JWTVerifier) VerifyToken ¶
func (v *JWTVerifier) VerifyToken(tokenStr string) (*UserClaims, error)
VerifyToken parses and validates tokenStr. It returns the embedded UserClaims on success, or one of the sentinel errors on failure:
- ErrTokenExpired – token exists but has expired
- ErrTokenInvalidSignature – signature does not match the key
- ErrTokenMalformed – string is not a valid JWT
- any other error – audience/issuer mismatch or internal failure
type JWTVerifierConfig ¶
type JWTVerifierConfig struct {
// Issuer is the expected "iss" claim value. When set, tokens with a
// different issuer are rejected.
Issuer string `yaml:"issuer"`
// Audience is the expected "aud" claim value. When set, tokens without
// this audience are rejected.
Audience string `yaml:"audience"`
// SigningMethod must match the algorithm used to sign the tokens.
// Supported values: hs256 (default), rs256, es256.
SigningMethod string `yaml:"signingMethod"`
// SecretKey is the HMAC verification secret (used with hs256).
SecretKey string `yaml:"secretKey"`
// PublicKey is the PEM-encoded RSA or ECDSA public key as an inline string
// (used with rs256 / es256). Takes precedence over PublicKeyFile.
PublicKey string `yaml:"publicKey"`
// PublicKeyFile is the path to a PEM-encoded RSA or ECDSA public key
// (used with rs256 / es256). Takes precedence over PrivateKey and PrivateKeyFile.
PublicKeyFile string `yaml:"publicKeyFile"`
// PrivateKey is the PEM-encoded RSA or ECDSA private key as an inline string.
// The public key is extracted from it and used for verification when
// PublicKey and PublicKeyFile are not set.
PrivateKey string `yaml:"privateKey"`
// PrivateKeyFile is the path to a PEM-encoded RSA or ECDSA private key.
// The public key is extracted from it and used for verification when
// PublicKey, PublicKeyFile, and PrivateKey are not set.
PrivateKeyFile string `yaml:"privateKeyFile"`
}
JWTVerifierConfig contains configuration for JWT token verification.
func (JWTVerifierConfig) GetPublicKey ¶
func (c JWTVerifierConfig) GetPublicKey() (string, error)
GetPublicKey returns the PEM-encoded public key for this JWT configuration. Resolution order: PublicKey (inline) → PublicKeyFile → PrivateKey (inline) → PrivateKeyFile.
type PolicyInput ¶
type PolicyInput struct {
Username string
Roles []string
Package string
Action string
Resource PolicyResource
Context map[string]string
Blueprint map[string]any // non-nil for workspace:* actions; decoded from context["blueprint"]
}
PolicyInput is the assembled input to a policy evaluation engine (e.g. OPA). It combines the decoded JWT subject with the validated, normalized fields from the gRPC EvaluateRequest. Construct via BuildPolicyInput.
func BuildPolicyInput ¶
func BuildPolicyInput(req *authzv1.EvaluateRequest) (*PolicyInput, error)
BuildPolicyInput parses the JWT from req, validates the request against the appropriate domain contract, and assembles the PolicyInput for the policy engine. It is the single entry point for all incoming EvaluateRequests on the server side — no per-domain routing is needed at the call site.
type PolicyResource ¶
PolicyResource holds the resource fields for policy evaluation, mirroring the proto Resource message.
type PolicyResult ¶
PolicyResult holds the outcome of a single policy evaluation.
func PolicyResultFromProto ¶
func PolicyResultFromProto(resp *authzv1.EvaluateResponse) *PolicyResult
PolicyResultFromProto converts a gRPC EvaluateResponse into a PolicyResult.
func (*PolicyResult) ToProto ¶
func (r *PolicyResult) ToProto() *authzv1.EvaluateResponse
ToProto converts a PolicyResult into a gRPC EvaluateResponse.
type ProvisionPatch ¶
ProvisionPatch is a single blueprint mutation expressed by the policy engine as part of a workspace:provision obligation. Path is a JSON Pointer (RFC 6901) addressing a field in the blueprint YAML document.
func ParseProvisionPatchObligations ¶
func ParseProvisionPatchObligations(obligations map[string]string) []ProvisionPatch
ParseProvisionPatchObligations extracts all patch obligations from the obligations map. Every key with the ObligationKeyPatchPrefix prefix is interpreted as a JSON Pointer path; the map value is the string to write there. Returns nil when no patch obligations are present.
type RecordObligation ¶
RecordObligation is the typed representation of the "record" obligation key returned by the policy engine in a PolicyResult for session:start. Each field corresponds to one recording channel; all default to false.
func ParseRecordObligation ¶
func ParseRecordObligation(obligations map[string]string) (RecordObligation, bool)
ParseRecordObligation reads the "record" key from the obligations map. The value is a comma-separated list of channel tokens ("shell", "exec", "direct-tcpip", "sftp"); "none" or an unrecognised value leaves all fields false. Returns (obligation, true) when the key is present, (zero, false) when the policy did not set a record obligation — the enforcer should then apply its configured default (typically no recording).
type RolesObligation ¶
type RolesObligation struct {
// Roles is the list of roles the policy assigns to the user.
Roles []models.Role
}
RolesObligation is the typed representation of the "roles" obligation key returned by the policy engine in a PolicyResult for user:onboard.
func ParseRolesObligation ¶
func ParseRolesObligation(obligations map[string]string) (RolesObligation, bool)
ParseRolesObligation reads the "roles" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set a roles obligation — in that case the enforcer should preserve its existing default rather than overwriting it.
type SSHAction ¶
type SSHAction string
SSHAction is the typed representation of an SSH policy action.
const ( // SSHActionShell is an interactive PTY session (session channel + shell request). SSHActionShell SSHAction = "ssh:shell" // SSHActionExec is a non-interactive command execution (session channel + exec request). // Also covers SCP. SSHActionExec SSHAction = "ssh:exec" // SSHActionSFTP is a subsystem "sftp" request on a session channel. SSHActionSFTP SSHAction = "ssh:sftp" // SSHActionDirectTCPIP is a client-initiated TCP port forward (direct-tcpip channel). SSHActionDirectTCPIP SSHAction = "ssh:direct-tcpip" // SSHActionDirectStreamlocal is a Unix domain socket forward // (direct-streamlocal@openssh.com channel). SSHActionDirectStreamlocal SSHAction = "ssh:direct-streamlocal" // SSHActionAgentForward is SSH agent forwarding // (auth-agent-req@openssh.com session request). SSHActionAgentForward SSHAction = "ssh:agent-forward" )
type SSHContext ¶
type SSHContext struct {
// PTY is true when a pseudo-terminal was requested (context["pty"] == "true").
PTY bool
// Command is the exact command string for ssh:exec channels (context["command"]).
Command string
// Host is the destination host for ssh:direct-tcpip channels (context["host"]).
Host string
// Port is the destination port for ssh:direct-tcpip channels (context["port"]).
Port string
// SocketPath is the Unix socket path for ssh:direct-streamlocal channels
// (context["socket_path"]).
SocketPath string
// AsUser is the Linux user the session runs as inside the workspace
// (context["as_user"]). Optional; empty means the workspace default user.
AsUser string
}
SSHContext holds the ambient SSH channel/request attributes supplied by the ssh-proxy in the context map of the EvaluateRequest.
type SSHEvalRequest ¶
type SSHEvalRequest struct {
Action SSHAction
Resource WorkspaceResource
Context SSHContext
}
SSHEvalRequest is the validated, typed model for SSH policy evaluation. Use NewSSHEvalRequest to start building, then chain With* methods and call Build to get a validated instance. Use SSHEvalRequestFromProto to convert directly from a gRPC EvaluateRequest.
func NewSSHEvalRequest ¶
func NewSSHEvalRequest(action SSHAction, workspaceID string) *SSHEvalRequest
NewSSHEvalRequest begins building an SSHEvalRequest for the given action and workspace ID. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func SSHEvalRequestFromProto ¶
func SSHEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SSHEvalRequest, error)
SSHEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SSHEvalRequest. Returns an error if the request does not conform to the SSH policy contract.
func (*SSHEvalRequest) Build ¶
func (r *SSHEvalRequest) Build() (*SSHEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*SSHEvalRequest) ToProto ¶
func (r *SSHEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Only non-empty / non-default context fields are included in the context map. Implements EvalRequest.
func (*SSHEvalRequest) Validate ¶
func (r *SSHEvalRequest) Validate() error
Validate checks the request against the SSH policy contract: the action must be recognized, core resource fields must be present, and each action enforces its own required context fields. Implements EvalRequest.
func (*SSHEvalRequest) WithAsUser ¶
func (r *SSHEvalRequest) WithAsUser(user string) *SSHEvalRequest
WithAsUser sets the Linux user the session runs as inside the workspace. Optional for SSHActionShell and SSHActionExec; empty means the workspace default user.
func (*SSHEvalRequest) WithBlueprint ¶
func (r *SSHEvalRequest) WithBlueprint(blueprint string) *SSHEvalRequest
WithBlueprint sets the blueprint name on the resource.
func (*SSHEvalRequest) WithCommand ¶
func (r *SSHEvalRequest) WithCommand(cmd string) *SSHEvalRequest
WithCommand sets the command string; required for SSHActionExec.
func (*SSHEvalRequest) WithHost ¶
func (r *SSHEvalRequest) WithHost(host string) *SSHEvalRequest
WithHost sets the destination host; required for SSHActionDirectTCPIP.
func (*SSHEvalRequest) WithOwner ¶
func (r *SSHEvalRequest) WithOwner(owner string) *SSHEvalRequest
WithOwner sets the workspace owner on the resource.
func (*SSHEvalRequest) WithPTY ¶
func (r *SSHEvalRequest) WithPTY(pty bool) *SSHEvalRequest
WithPTY records whether a pseudo-terminal was requested.
func (*SSHEvalRequest) WithPort ¶
func (r *SSHEvalRequest) WithPort(port string) *SSHEvalRequest
WithPort sets the destination port; required for SSHActionDirectTCPIP.
func (*SSHEvalRequest) WithSocketPath ¶
func (r *SSHEvalRequest) WithSocketPath(path string) *SSHEvalRequest
WithSocketPath sets the Unix socket path; required for SSHActionDirectStreamlocal.
type Scope ¶
type Scope string
Scope is a PAT access token scope string. It is either an exact action string from the registry (e.g. "workspace:list") or a wildcard pattern with "*" as the last segment (e.g. "workspace:connect:*").
Grammar:
scope = "*"
| domain ":" action
| domain ":" action ":" qualifier
| domain ":" action ":" "*"
| domain ":" "*"
Matching is strict (Option A): a scope without a wildcard matches only its exact action string. To cover all qualifiers of an action, the scope must carry an explicit ":*" suffix (e.g. "workspace:connect:*").
type ScopesObligation ¶
type ScopesObligation struct {
// Scopes is the list of scopes the policy permits on the new token.
Scopes []string
}
ScopesObligation is the typed representation of the "scopes" obligation key returned by the policy engine in a PolicyResult for token:create.
func ParseScopesObligation ¶
func ParseScopesObligation(obligations map[string]string) (ScopesObligation, bool)
ParseScopesObligation reads the "scopes" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set a scopes obligation.
type SessionAction ¶
type SessionAction string
SessionAction is the typed representation of a session policy action.
const ( // SessionActionStart is the action evaluated when a new session is being // established. The policy result may carry a "record" obligation that // instructs the enforcer what kind of recording to apply to the session. SessionActionStart SessionAction = "session:start" // SessionActionList is the action evaluated when listing sessions. The // scope is controlled by the resource fields: both id and owner set scopes // to one workspace; owner only scopes to a user; neither means all sessions. SessionActionList SessionAction = "session:list" )
type SessionContext ¶
type SessionContext struct {
// Type is the kind of session being established (context["session_type"]).
Type SessionType
// Source is the component that initiated the session (context["session_source"]).
Source SessionSource
}
SessionContext holds the ambient session attributes supplied by the caller in the context map of the EvaluateRequest.
type SessionListEvalRequest ¶
type SessionListEvalRequest struct {
Resource WorkspaceResource
}
SessionListEvalRequest is the validated, typed model for session:list policy evaluation. Both resource fields are optional; their combination controls the listing scope (see the contract comment at the top of this file).
func NewSessionListEvalRequest ¶
func NewSessionListEvalRequest() *SessionListEvalRequest
NewSessionListEvalRequest returns a SessionListEvalRequest ready to be built. Chain WithWorkspace and/or WithOwner to narrow the scope, then call Build.
func SessionListEvalRequestFromProto ¶
func SessionListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SessionListEvalRequest, error)
SessionListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SessionListEvalRequest.
func (*SessionListEvalRequest) Build ¶
func (r *SessionListEvalRequest) Build() (*SessionListEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*SessionListEvalRequest) ToProto ¶
func (r *SessionListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*SessionListEvalRequest) Validate ¶
func (r *SessionListEvalRequest) Validate() error
Validate checks the request: if a workspace id is set, owner must also be set. Implements EvalRequest.
func (*SessionListEvalRequest) WithOwner ¶
func (r *SessionListEvalRequest) WithOwner(owner string) *SessionListEvalRequest
WithOwner sets the owner username.
func (*SessionListEvalRequest) WithWorkspace ¶
func (r *SessionListEvalRequest) WithWorkspace(workspaceID string) *SessionListEvalRequest
WithWorkspace sets the workspace name; requires WithOwner to also be called.
type SessionSource ¶
type SessionSource string
SessionSource identifies the component that initiated the session.
const ( // SessionSourceSSHProxy is set when the session originates from the SSH proxy. SessionSourceSSHProxy SessionSource = "ssh-proxy" // SessionSourceAPIServer is set when the session originates from the API server. SessionSourceAPIServer SessionSource = "api-server" )
type SessionStartEvalRequest ¶
type SessionStartEvalRequest struct {
Action SessionAction
Resource WorkspaceResource
Context SessionContext
}
SessionStartEvalRequest is the validated, typed model for session policy evaluation. Use NewSessionStartEvalRequest to start building, then chain With* methods and call Build to get a validated instance. Use SessionStartEvalRequestFromProto to convert directly from a gRPC EvaluateRequest.
func NewSessionStartEvalRequest ¶
func NewSessionStartEvalRequest(action SessionAction, workspaceID string, sessionType SessionType) *SessionStartEvalRequest
NewSessionStartEvalRequest begins building a SessionStartEvalRequest for the given action, workspace ID, and session type. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func SessionStartEvalRequestFromProto ¶
func SessionStartEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SessionStartEvalRequest, error)
SessionStartEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SessionStartEvalRequest. Returns an error if the request does not conform to the session policy contract.
func (*SessionStartEvalRequest) Build ¶
func (r *SessionStartEvalRequest) Build() (*SessionStartEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*SessionStartEvalRequest) ToProto ¶
func (r *SessionStartEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Only non-empty resource attributes are included. Implements EvalRequest.
func (*SessionStartEvalRequest) Validate ¶
func (r *SessionStartEvalRequest) Validate() error
Validate checks the request against the session policy contract: the action must be recognized, core resource fields must be present, and the session type must be a known value. Implements EvalRequest.
func (*SessionStartEvalRequest) WithBlueprint ¶
func (r *SessionStartEvalRequest) WithBlueprint(blueprint string) *SessionStartEvalRequest
WithBlueprint sets the blueprint name on the resource.
func (*SessionStartEvalRequest) WithOwner ¶
func (r *SessionStartEvalRequest) WithOwner(owner string) *SessionStartEvalRequest
WithOwner sets the workspace owner on the resource.
func (*SessionStartEvalRequest) WithSource ¶
func (r *SessionStartEvalRequest) WithSource(source SessionSource) *SessionStartEvalRequest
WithSource sets the session source on the context.
type SessionType ¶
type SessionType string
SessionType describes the kind of session being established.
const ( // SessionTypeShell is an interactive shell/PTY session (terminal recording). SessionTypeShell SessionType = "shell" // SessionTypeTCPIP is a TCP/IP port-forwarding session (network traffic recording). SessionTypeTCPIP SessionType = "tcpip" // SessionTypeExec is a non-interactive exec session (single command, no PTY). SessionTypeExec SessionType = "exec" // SessionTypeSFTP is an SFTP subsystem session (file transfer). SessionTypeSFTP SessionType = "sftp" )
type SudoObligation ¶
type SudoObligation struct {
// Granted is true when the policy grants sudo access, false when it denies it.
Granted bool
}
SudoObligation is the typed representation of the "sudo" obligation key returned by the policy engine in a PolicyResult for user:onboard.
func ParseSudoObligation ¶
func ParseSudoObligation(obligations map[string]string) (SudoObligation, bool)
ParseSudoObligation reads the "sudo" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set a sudo obligation — in that case the enforcer should preserve its existing default rather than overwriting it.
type TokenCreateContext ¶
type TokenCreateContext struct {
// Source is how the token creation was initiated (context["source"]).
Source TokenCreateSource
}
TokenCreateContext holds the ambient attributes for a token:create request.
type TokenCreateSource ¶
type TokenCreateSource string
TokenCreateSource identifies how the token creation was initiated.
const ( // TokenCreateSourceWebFlow is set when the token is issued at the end of an // OAuth/device login flow initiated by the CLI. TokenCreateSourceWebFlow TokenCreateSource = "web-flow" // TokenCreateSourceAPI is set when the token is created via a direct API request. TokenCreateSourceAPI TokenCreateSource = "api" )
type UserAuthContext ¶
type UserAuthContext struct {
// Method is the SSH authentication method ("publickey" or "password").
Method UserAuthMethod
// Fingerprint is the SHA256 public key fingerprint; set only when
// Method is UserAuthMethodPublicKey (context["fingerprint"]).
Fingerprint string
}
UserAuthContext holds the ambient authentication attributes for user:auth.
type UserAuthEvalRequest ¶
type UserAuthEvalRequest struct {
Resource UserResource
Context UserAuthContext
}
UserAuthEvalRequest is the validated, typed model for user:auth policy evaluation. Use NewUserAuthEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
func NewUserAuthEvalRequest ¶
func NewUserAuthEvalRequest(username string) *UserAuthEvalRequest
NewUserAuthEvalRequest begins building a UserAuthEvalRequest for the given username. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func UserAuthEvalRequestFromProto ¶
func UserAuthEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserAuthEvalRequest, error)
UserAuthEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserAuthEvalRequest. Returns an error if the request does not conform to the user:auth contract.
func (*UserAuthEvalRequest) Build ¶
func (r *UserAuthEvalRequest) Build() (*UserAuthEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserAuthEvalRequest) ToProto ¶
func (r *UserAuthEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserAuthEvalRequest) Validate ¶
func (r *UserAuthEvalRequest) Validate() error
Validate checks the request against the user:auth contract: ID and IDP are required, method must be set, and publickey auth requires a fingerprint. Implements EvalRequest.
func (*UserAuthEvalRequest) WithAuthMethod ¶
func (r *UserAuthEvalRequest) WithAuthMethod(method UserAuthMethod) *UserAuthEvalRequest
WithAuthMethod sets the authentication method.
func (*UserAuthEvalRequest) WithFingerprint ¶
func (r *UserAuthEvalRequest) WithFingerprint(fp string) *UserAuthEvalRequest
WithFingerprint sets the public key fingerprint; required for publickey auth.
func (*UserAuthEvalRequest) WithIDP ¶
func (r *UserAuthEvalRequest) WithIDP(idp string) *UserAuthEvalRequest
WithIDP sets the identity provider name on the resource.
func (*UserAuthEvalRequest) WithOrg ¶
func (r *UserAuthEvalRequest) WithOrg(org string) *UserAuthEvalRequest
WithOrg sets the organization on the resource.
type UserAuthMethod ¶
type UserAuthMethod string
UserAuthMethod is the typed representation of an SSH authentication method.
const ( UserAuthMethodPublicKey UserAuthMethod = "publickey" UserAuthMethodPassword UserAuthMethod = "password" )
type UserClaims ¶
type UserClaims struct {
jwt.RegisteredClaims
// Email is the user's email address.
Email string `json:"email,omitempty"`
// Name is the user's full name.
Name string `json:"name,omitempty"`
// UID is the POSIX user-id of the user.
UID uint32 `json:"uid"`
// GID is the POSIX primary group-id of the user.
GID uint32 `json:"gid"`
// Roles lists the roles granted to the user.
Roles []models.Role `json:"roles,omitempty"`
// Organization is the user's organisation.
Organization string `json:"org,omitempty"`
// Source identifies the identity provider that owns this user record.
Source string `json:"source,omitempty"`
// Shell is the user's default login shell.
Shell string `json:"shell,omitempty"`
// Sudo indicates whether the user has sudo privileges.
Sudo bool `json:"sudo,omitempty"`
}
UserClaims are the JWT claims embedded in tokens issued for a user. Standard registered claims are promoted from jwt.RegisteredClaims; the remaining fields carry k8Shell-specific user attributes.
func ParseUnverifiedClaims ¶
func ParseUnverifiedClaims(tokenStr string, checkExp bool) (*UserClaims, error)
ParseUnverifiedClaims decodes the claims from tokenStr without verifying the signature or validating any registered claims (exp, iss, aud, etc.). Use this only where the token has already been verified by another means, or when you need to inspect claims (e.g. check expiry) before a full verify.
func (*UserClaims) GetUsername ¶
func (c *UserClaims) GetUsername() string
type UserDataType ¶
type UserDataType string
UserDataType identifies which slice of user data is being accessed in user:read and user:write. UserDataTypeSudo and UserDataTypeLocked are write-only values: user:read never selects them individually, since UserDataTypeProfile already returns the full profile view including sudo and locked.
const ( UserDataTypeProfile UserDataType = "profile" UserDataTypeCredentials UserDataType = "credentials" UserDataTypeBlueprints UserDataType = "blueprints" UserDataTypeRoles UserDataType = "roles" UserDataTypeSudo UserDataType = "sudo" UserDataTypeLocked UserDataType = "locked" )
type UserListEvalRequest ¶
type UserListEvalRequest struct{}
UserListEvalRequest is the validated, typed model for user:list policy evaluation. No resource id is required; the subject claims determine access.
func NewUserListEvalRequest ¶
func NewUserListEvalRequest() *UserListEvalRequest
NewUserListEvalRequest returns a UserListEvalRequest ready to be built.
func UserListEvalRequestFromProto ¶
func UserListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserListEvalRequest, error)
UserListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserListEvalRequest.
func (*UserListEvalRequest) Build ¶
func (r *UserListEvalRequest) Build() (*UserListEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*UserListEvalRequest) ToProto ¶
func (r *UserListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserListEvalRequest) Validate ¶
func (r *UserListEvalRequest) Validate() error
Validate is a no-op for user:list; no fields are required. Implements EvalRequest.
type UserOnboardEvalRequest ¶
type UserOnboardEvalRequest struct {
Resource UserResource
}
UserOnboardEvalRequest is the validated, typed model for user:onboard policy evaluation. Use NewUserOnboardEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
func NewUserOnboardEvalRequest ¶
func NewUserOnboardEvalRequest(username string) *UserOnboardEvalRequest
NewUserOnboardEvalRequest begins building a UserOnboardEvalRequest for the given username. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func UserOnboardEvalRequestFromProto ¶
func UserOnboardEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserOnboardEvalRequest, error)
UserOnboardEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserOnboardEvalRequest. Returns an error if the request does not conform to the user:onboard contract.
func (*UserOnboardEvalRequest) Build ¶
func (r *UserOnboardEvalRequest) Build() (*UserOnboardEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserOnboardEvalRequest) ToProto ¶
func (r *UserOnboardEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserOnboardEvalRequest) Validate ¶
func (r *UserOnboardEvalRequest) Validate() error
Validate checks the request against the user:onboard contract. Implements EvalRequest.
func (*UserOnboardEvalRequest) WithIDP ¶
func (r *UserOnboardEvalRequest) WithIDP(idp string) *UserOnboardEvalRequest
WithIDP sets the identity provider name on the resource.
func (*UserOnboardEvalRequest) WithOrg ¶
func (r *UserOnboardEvalRequest) WithOrg(org string) *UserOnboardEvalRequest
WithOrg sets the organization on the resource.
type UserReadEvalRequest ¶
type UserReadEvalRequest struct {
Resource UserResource
DataType UserDataType
}
UserReadEvalRequest is the validated, typed model for user:read policy evaluation. Use NewUserReadEvalRequest to start building, then call Build to get a validated instance.
func NewUserReadEvalRequest ¶
func NewUserReadEvalRequest(username string) *UserReadEvalRequest
NewUserReadEvalRequest begins building a UserReadEvalRequest for the given target username.
func UserReadEvalRequestFromProto ¶
func UserReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserReadEvalRequest, error)
UserReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserReadEvalRequest.
func (*UserReadEvalRequest) Build ¶
func (r *UserReadEvalRequest) Build() (*UserReadEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserReadEvalRequest) ToProto ¶
func (r *UserReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserReadEvalRequest) Validate ¶
func (r *UserReadEvalRequest) Validate() error
Validate checks the request against the user:read contract. Implements EvalRequest.
func (*UserReadEvalRequest) WithDataType ¶
func (r *UserReadEvalRequest) WithDataType(dt UserDataType) *UserReadEvalRequest
WithDataType sets the data type being accessed.
type UserResource ¶
type UserResource struct {
// ID is the username (resource.id in the EvaluateRequest).
ID string
// IDP is the identity provider through which the user was onboarded
// (resource.attributes["idp"]).
IDP string
// Org is the user's organization (resource.attributes["org"]).
Org string
}
UserResource holds the resource-scoped attributes for a user policy check.
type UserTokenCreateEvalRequest ¶
type UserTokenCreateEvalRequest struct {
Resource UserResource
Context TokenCreateContext
}
UserTokenCreateEvalRequest is the validated, typed model for token:create policy evaluation. The resource ID is the username of the token owner.
func NewUserTokenCreateEvalRequest ¶
func NewUserTokenCreateEvalRequest(username string) *UserTokenCreateEvalRequest
NewUserTokenCreateEvalRequest begins building a UserTokenCreateEvalRequest for the given username (the token owner). Call WithSource then Build.
func UserTokenCreateEvalRequestFromProto ¶
func UserTokenCreateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserTokenCreateEvalRequest, error)
UserTokenCreateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserTokenCreateEvalRequest.
func (*UserTokenCreateEvalRequest) Build ¶
func (r *UserTokenCreateEvalRequest) Build() (*UserTokenCreateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserTokenCreateEvalRequest) ToProto ¶
func (r *UserTokenCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserTokenCreateEvalRequest) Validate ¶
func (r *UserTokenCreateEvalRequest) Validate() error
Validate checks the request against the token:create contract. Implements EvalRequest.
func (*UserTokenCreateEvalRequest) WithSource ¶
func (r *UserTokenCreateEvalRequest) WithSource(source TokenCreateSource) *UserTokenCreateEvalRequest
WithSource sets the token creation source on the context.
type UserTokenReadEvalRequest ¶
type UserTokenReadEvalRequest struct {
Resource UserResource
}
UserTokenReadEvalRequest is the validated, typed model for token:read policy evaluation. The resource ID is the username whose tokens are being read.
func NewUserTokenReadEvalRequest ¶
func NewUserTokenReadEvalRequest(username string) *UserTokenReadEvalRequest
NewUserTokenReadEvalRequest begins building a UserTokenReadEvalRequest for the given username (the token owner). Call Build to validate.
func UserTokenReadEvalRequestFromProto ¶
func UserTokenReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserTokenReadEvalRequest, error)
UserTokenReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserTokenReadEvalRequest.
func (*UserTokenReadEvalRequest) Build ¶
func (r *UserTokenReadEvalRequest) Build() (*UserTokenReadEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserTokenReadEvalRequest) ToProto ¶
func (r *UserTokenReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserTokenReadEvalRequest) Validate ¶
func (r *UserTokenReadEvalRequest) Validate() error
Validate checks the request against the token:read contract. Implements EvalRequest.
type UserWriteEvalRequest ¶ added in v0.29.11
type UserWriteEvalRequest struct {
Resource UserResource
DataType UserDataType
}
UserWriteEvalRequest is the validated, typed model for user:write policy evaluation. It covers all mutations to a user record: profile fields, roles, blueprints, and auth keys. Use NewUserWriteEvalRequest to build it.
func NewUserWriteEvalRequest ¶ added in v0.29.11
func NewUserWriteEvalRequest(username string) *UserWriteEvalRequest
NewUserWriteEvalRequest begins building a UserWriteEvalRequest for the given target username. Call WithDataType then Build to validate and obtain the final struct.
func UserWriteEvalRequestFromProto ¶ added in v0.29.11
func UserWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserWriteEvalRequest, error)
UserWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserWriteEvalRequest.
func (*UserWriteEvalRequest) Build ¶ added in v0.29.11
func (r *UserWriteEvalRequest) Build() (*UserWriteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserWriteEvalRequest) ToProto ¶ added in v0.29.11
func (r *UserWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserWriteEvalRequest) Validate ¶ added in v0.29.11
func (r *UserWriteEvalRequest) Validate() error
Validate checks the request against the user:write contract. Implements EvalRequest.
func (*UserWriteEvalRequest) WithDataType ¶ added in v0.29.13
func (r *UserWriteEvalRequest) WithDataType(dt UserDataType) *UserWriteEvalRequest
WithDataType sets the data type being mutated.
type WorkspaceAccessEvalRequest ¶
type WorkspaceAccessEvalRequest struct {
Action WorkspaceAction
Resource WorkspaceResource
}
WorkspaceAccessEvalRequest is the validated, typed model for workspace:read and workspace:delete. The resource id is the workspace name; the owner attribute identifies who owns it.
func NewWorkspaceAccessEvalRequest ¶
func NewWorkspaceAccessEvalRequest(action WorkspaceAction, workspaceName string) *WorkspaceAccessEvalRequest
NewWorkspaceAccessEvalRequest begins building a WorkspaceAccessEvalRequest.
func WorkspaceAccessEvalRequestFromProto ¶
func WorkspaceAccessEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceAccessEvalRequest, error)
WorkspaceAccessEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceAccessEvalRequest.
func (*WorkspaceAccessEvalRequest) Build ¶
func (r *WorkspaceAccessEvalRequest) Build() (*WorkspaceAccessEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceAccessEvalRequest) ToProto ¶
func (r *WorkspaceAccessEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceAccessEvalRequest) Validate ¶
func (r *WorkspaceAccessEvalRequest) Validate() error
Validate checks the request against the workspace:read / workspace:delete contract. Implements EvalRequest.
func (*WorkspaceAccessEvalRequest) WithOwner ¶
func (r *WorkspaceAccessEvalRequest) WithOwner(owner string) *WorkspaceAccessEvalRequest
WithOwner sets the owner username on the resource.
type WorkspaceAction ¶
type WorkspaceAction string
WorkspaceAction is the typed representation of a workspace policy action.
const ( // WorkspaceActionProvision is the action evaluated before a workspace is // provisioned. The full blueprint is carried in context["blueprint"] as a // YAML string. The policy result may carry patch obligations (keys prefixed // with ObligationKeyPatchPrefix) that the enforcer must apply to the // blueprint before provisioning proceeds. WorkspaceActionProvision WorkspaceAction = "workspace:provision" WorkspaceActionList WorkspaceAction = "workspace:list" WorkspaceActionCreate WorkspaceAction = "workspace:create" WorkspaceActionRead WorkspaceAction = "workspace:read" WorkspaceActionDelete WorkspaceAction = "workspace:delete" WorkspaceActionConnect WorkspaceAction = "workspace:connect" WorkspaceActionFiles WorkspaceAction = "workspace:files" WorkspaceActionApp WorkspaceAction = "workspace:app" )
type WorkspaceAppEvalRequest ¶
type WorkspaceAppEvalRequest struct {
Resource WorkspaceResource
App string
Op WorkspaceAppOp
}
WorkspaceAppEvalRequest is the validated, typed model for workspace:app.
func NewWorkspaceAppEvalRequest ¶
func NewWorkspaceAppEvalRequest(workspaceName, appName string) *WorkspaceAppEvalRequest
NewWorkspaceAppEvalRequest begins building a WorkspaceAppEvalRequest for the given workspace name and app name.
func WorkspaceAppEvalRequestFromProto ¶
func WorkspaceAppEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceAppEvalRequest, error)
WorkspaceAppEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceAppEvalRequest.
func (*WorkspaceAppEvalRequest) Build ¶
func (r *WorkspaceAppEvalRequest) Build() (*WorkspaceAppEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceAppEvalRequest) ToProto ¶
func (r *WorkspaceAppEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceAppEvalRequest) Validate ¶
func (r *WorkspaceAppEvalRequest) Validate() error
Validate checks the request against the workspace:app contract. Implements EvalRequest.
func (*WorkspaceAppEvalRequest) WithOp ¶
func (r *WorkspaceAppEvalRequest) WithOp(op WorkspaceAppOp) *WorkspaceAppEvalRequest
WithOp sets the app operation.
func (*WorkspaceAppEvalRequest) WithOwner ¶
func (r *WorkspaceAppEvalRequest) WithOwner(owner string) *WorkspaceAppEvalRequest
WithOwner sets the owner username on the resource.
type WorkspaceAppOp ¶
type WorkspaceAppOp string
WorkspaceAppOp is the operation applied to an app for workspace:app.
const ( WorkspaceAppOpRead WorkspaceAppOp = "read" WorkspaceAppOpInstall WorkspaceAppOp = "install" WorkspaceAppOpStart WorkspaceAppOp = "start" WorkspaceAppOpStop WorkspaceAppOp = "stop" )
type WorkspaceConnectContext ¶
type WorkspaceConnectContext struct {
Type WorkspaceConnectType
Port string // non-empty only when Type is WorkspaceConnectTypePortForward
}
WorkspaceConnectContext holds the session type and optional port for workspace:connect.
type WorkspaceConnectEvalRequest ¶
type WorkspaceConnectEvalRequest struct {
Resource WorkspaceResource
Context WorkspaceConnectContext
}
WorkspaceConnectEvalRequest is the validated, typed model for workspace:connect.
func NewWorkspaceConnectEvalRequest ¶
func NewWorkspaceConnectEvalRequest(workspaceName string) *WorkspaceConnectEvalRequest
NewWorkspaceConnectEvalRequest begins building a WorkspaceConnectEvalRequest for the given workspace name.
func WorkspaceConnectEvalRequestFromProto ¶
func WorkspaceConnectEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceConnectEvalRequest, error)
WorkspaceConnectEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceConnectEvalRequest.
func (*WorkspaceConnectEvalRequest) Build ¶
func (r *WorkspaceConnectEvalRequest) Build() (*WorkspaceConnectEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceConnectEvalRequest) ToProto ¶
func (r *WorkspaceConnectEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceConnectEvalRequest) Validate ¶
func (r *WorkspaceConnectEvalRequest) Validate() error
Validate checks the request against the workspace:connect contract. Implements EvalRequest.
func (*WorkspaceConnectEvalRequest) WithOwner ¶
func (r *WorkspaceConnectEvalRequest) WithOwner(owner string) *WorkspaceConnectEvalRequest
WithOwner sets the owner username on the resource.
func (*WorkspaceConnectEvalRequest) WithPort ¶
func (r *WorkspaceConnectEvalRequest) WithPort(port string) *WorkspaceConnectEvalRequest
WithPort sets the port; required when type is WorkspaceConnectTypePortForward.
func (*WorkspaceConnectEvalRequest) WithType ¶
func (r *WorkspaceConnectEvalRequest) WithType(t WorkspaceConnectType) *WorkspaceConnectEvalRequest
WithType sets the connection type.
type WorkspaceConnectType ¶
type WorkspaceConnectType string
WorkspaceConnectType is the kind of interactive session for workspace:connect.
const ( WorkspaceConnectTypeWebshell WorkspaceConnectType = "webshell" WorkspaceConnectTypeWebfiles WorkspaceConnectType = "webfiles" WorkspaceConnectTypePortForward WorkspaceConnectType = "portforward" )
type WorkspaceEvalRequest ¶
type WorkspaceEvalRequest struct {
Action WorkspaceAction
Resource WorkspaceResource
Context WorkspaceProvisionContext
}
WorkspaceEvalRequest is the validated, typed model for workspace policy evaluation. Use NewWorkspaceEvalRequest to start building, then chain With* methods and call Build to get a validated instance. Use WorkspaceEvalRequestFromProto to convert directly from a gRPC EvaluateRequest.
func NewWorkspaceEvalRequest ¶
func NewWorkspaceEvalRequest(action WorkspaceAction, workspaceID string) *WorkspaceEvalRequest
NewWorkspaceEvalRequest begins building a WorkspaceEvalRequest for the given action and workspace ID. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func WorkspaceEvalRequestFromProto ¶
func WorkspaceEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceEvalRequest, error)
WorkspaceEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceEvalRequest. Returns an error if the request does not conform to the workspace policy contract.
func (*WorkspaceEvalRequest) Build ¶
func (r *WorkspaceEvalRequest) Build() (*WorkspaceEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*WorkspaceEvalRequest) ToProto ¶
func (r *WorkspaceEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. The blueprint is marshaled to YAML and carried in context["blueprint"]. Implements EvalRequest.
func (*WorkspaceEvalRequest) Validate ¶
func (r *WorkspaceEvalRequest) Validate() error
Validate checks the request against the workspace policy contract: the action must be recognized, and resource ID, owner, and blueprint context are all required for workspace:provision. Implements EvalRequest.
func (*WorkspaceEvalRequest) WithBlueprint ¶
func (r *WorkspaceEvalRequest) WithBlueprint(bp *models.Blueprint) *WorkspaceEvalRequest
WithBlueprint sets the full blueprint struct in the provision context; required for WorkspaceActionProvision.
func (*WorkspaceEvalRequest) WithBlueprintName ¶
func (r *WorkspaceEvalRequest) WithBlueprintName(name string) *WorkspaceEvalRequest
WithBlueprintName sets the blueprint name on the resource attributes.
func (*WorkspaceEvalRequest) WithMode ¶
func (r *WorkspaceEvalRequest) WithMode(mode WorkspaceProvisionMode) *WorkspaceEvalRequest
WithMode sets the provisioning mode; required for WorkspaceActionProvision.
func (*WorkspaceEvalRequest) WithOwner ¶
func (r *WorkspaceEvalRequest) WithOwner(owner string) *WorkspaceEvalRequest
WithOwner sets the username of the user provisioning the workspace.
func (*WorkspaceEvalRequest) WithWorkload ¶
func (r *WorkspaceEvalRequest) WithWorkload(name, namespace, kind string) *WorkspaceEvalRequest
WithWorkload sets the target workload fields; required when mode is WorkspaceProvisionModeInject.
type WorkspaceFilesEvalRequest ¶
type WorkspaceFilesEvalRequest struct {
Resource WorkspaceResource
Op WorkspaceFilesOp
}
WorkspaceFilesEvalRequest is the validated, typed model for workspace:files.
func NewWorkspaceFilesEvalRequest ¶
func NewWorkspaceFilesEvalRequest(workspaceName string) *WorkspaceFilesEvalRequest
NewWorkspaceFilesEvalRequest begins building a WorkspaceFilesEvalRequest for the given workspace name.
func WorkspaceFilesEvalRequestFromProto ¶
func WorkspaceFilesEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceFilesEvalRequest, error)
WorkspaceFilesEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceFilesEvalRequest.
func (*WorkspaceFilesEvalRequest) Build ¶
func (r *WorkspaceFilesEvalRequest) Build() (*WorkspaceFilesEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceFilesEvalRequest) ToProto ¶
func (r *WorkspaceFilesEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceFilesEvalRequest) Validate ¶
func (r *WorkspaceFilesEvalRequest) Validate() error
Validate checks the request against the workspace:files contract. Implements EvalRequest.
func (*WorkspaceFilesEvalRequest) WithOp ¶
func (r *WorkspaceFilesEvalRequest) WithOp(op WorkspaceFilesOp) *WorkspaceFilesEvalRequest
WithOp sets the file transfer direction.
func (*WorkspaceFilesEvalRequest) WithOwner ¶
func (r *WorkspaceFilesEvalRequest) WithOwner(owner string) *WorkspaceFilesEvalRequest
WithOwner sets the owner username on the resource.
type WorkspaceFilesOp ¶
type WorkspaceFilesOp string
WorkspaceFilesOp is the direction of file transfer for workspace:files.
const ( WorkspaceFilesOpDownload WorkspaceFilesOp = "download" WorkspaceFilesOpUpload WorkspaceFilesOp = "upload" )
type WorkspaceOwnerEvalRequest ¶
type WorkspaceOwnerEvalRequest struct {
Action WorkspaceAction
Resource WorkspaceResource
}
WorkspaceOwnerEvalRequest is the validated, typed model for workspace:list and workspace:create. Resource.ID is empty — there is no specific workspace; Resource.Owner identifies whose workspace collection is being accessed or extended.
func NewWorkspaceOwnerEvalRequest ¶
func NewWorkspaceOwnerEvalRequest(action WorkspaceAction, owner string) *WorkspaceOwnerEvalRequest
NewWorkspaceOwnerEvalRequest begins building a WorkspaceOwnerEvalRequest for the given action and owner username.
func WorkspaceOwnerEvalRequestFromProto ¶
func WorkspaceOwnerEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceOwnerEvalRequest, error)
WorkspaceOwnerEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceOwnerEvalRequest.
func (*WorkspaceOwnerEvalRequest) Build ¶
func (r *WorkspaceOwnerEvalRequest) Build() (*WorkspaceOwnerEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceOwnerEvalRequest) ToProto ¶
func (r *WorkspaceOwnerEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceOwnerEvalRequest) Validate ¶
func (r *WorkspaceOwnerEvalRequest) Validate() error
Validate checks the request against the workspace:list / workspace:create contract. Implements EvalRequest.
type WorkspaceProvisionContext ¶
type WorkspaceProvisionContext struct {
Blueprint *models.Blueprint
Mode WorkspaceProvisionMode
WorkloadName string
WorkloadNamespace string
WorkloadKind string
}
WorkspaceProvisionContext holds the full blueprint being provisioned and the provisioning mode. The enforcer must apply any ProvisionPatch obligations to Blueprint before provisioning proceeds.
type WorkspaceProvisionMode ¶
type WorkspaceProvisionMode string
WorkspaceProvisionMode controls how the workspace is attached to its runtime.
const ( // WorkspaceProvisionModeStandalone creates a new independent workspace pod. WorkspaceProvisionModeStandalone WorkspaceProvisionMode = "standalone" // WorkspaceProvisionModeInject injects the workspace into an existing // workload. WorkloadName, WorkloadNamespace, and WorkloadKind are required. WorkspaceProvisionModeInject WorkspaceProvisionMode = "inject" )
type WorkspaceResource ¶
type WorkspaceResource struct {
// ID is the workspace name (resource.id in the EvaluateRequest).
ID string
// Owner is the username of the user provisioning the workspace
// (resource.attributes["owner"]).
Owner string
// Blueprint is the blueprint name (resource.attributes["blueprint"]).
Blueprint string
}
WorkspaceResource holds the resource-scoped attributes for a workspace policy check.