Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyProvisionPatches(bp *models.Blueprint, patches []ProvisionPatch) (*models.Blueprint, error)
- func ScopeAllows(scopes []string, action string, satisfied ...ScopeConstraint) bool
- func ValidateDetectObligation(v string) error
- func ValidateRecordObligation(v string) error
- func ValidateScope(s string) error
- func ValidateScopes(scopes []string) error
- type AnnouncementResource
- type AnnouncementWriteEvalRequest
- func (r *AnnouncementWriteEvalRequest) Build() (*AnnouncementWriteEvalRequest, error)
- func (r *AnnouncementWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *AnnouncementWriteEvalRequest) Validate() error
- func (r *AnnouncementWriteEvalRequest) WithOrgs(orgs []string) *AnnouncementWriteEvalRequest
- func (r *AnnouncementWriteEvalRequest) WithRoles(roles []string) *AnnouncementWriteEvalRequest
- type AuditListEvalRequest
- type AuthMethodsObligation
- type AuthSurface
- type BlueprintReadEvalRequest
- type BlueprintWriteEvalRequest
- type BlueprintsObligation
- type CapabilityCheck
- type CapabilityContext
- type DetectObligation
- type EvalRequest
- type ExpiresInObligation
- type GitAction
- type GitContext
- type GitEvalRequest
- type GitResource
- type GlobalRolesObligation
- type JWTIssuer
- type JWTIssuerConfig
- type JWTVerifier
- type JWTVerifierConfig
- type OnboardRuleCreateEvalRequest
- func (r *OnboardRuleCreateEvalRequest) Build() (*OnboardRuleCreateEvalRequest, error)
- func (r *OnboardRuleCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *OnboardRuleCreateEvalRequest) Validate() error
- func (r *OnboardRuleCreateEvalRequest) WithIDP(idp string) *OnboardRuleCreateEvalRequest
- func (r *OnboardRuleCreateEvalRequest) WithOrg(org string) *OnboardRuleCreateEvalRequest
- type OnboardRuleDeleteEvalRequest
- func (r *OnboardRuleDeleteEvalRequest) Build() (*OnboardRuleDeleteEvalRequest, error)
- func (r *OnboardRuleDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *OnboardRuleDeleteEvalRequest) Validate() error
- func (r *OnboardRuleDeleteEvalRequest) WithOrg(org string) *OnboardRuleDeleteEvalRequest
- type OnboardRuleListEvalRequest
- type OnboardRuleResource
- type OnboardRuleUpdateEvalRequest
- func (r *OnboardRuleUpdateEvalRequest) Build() (*OnboardRuleUpdateEvalRequest, error)
- func (r *OnboardRuleUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *OnboardRuleUpdateEvalRequest) Validate() error
- func (r *OnboardRuleUpdateEvalRequest) WithOrg(org string) *OnboardRuleUpdateEvalRequest
- type OrgObligation
- type OrganizationCreateEvalRequest
- type OrganizationDeleteEvalRequest
- type OrganizationEnvVarReadEvalRequest
- type OrganizationEnvVarWriteEvalRequest
- type OrganizationListEvalRequest
- type OrganizationNodeWriteEvalRequest
- type OrganizationReadEvalRequest
- type OrganizationResource
- type OrganizationUpdateEvalRequest
- type PolicyInput
- type PolicyResource
- type PolicyResult
- type ProvisionPatch
- type RecordObligation
- type RoleCreateEvalRequest
- type RoleDeleteEvalRequest
- type RoleListEvalRequest
- type RoleResource
- type RoleUpdateEvalRequest
- 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 ScopeCatalog
- type ScopeCatalogAction
- type ScopeCatalogDomain
- type ScopeCatalogEntry
- type ScopeConstraint
- 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 SessionRecordEvalRequest
- func (r *SessionRecordEvalRequest) Build() (*SessionRecordEvalRequest, error)
- func (r *SessionRecordEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SessionRecordEvalRequest) Validate() error
- func (r *SessionRecordEvalRequest) WithBlueprint(blueprint string) *SessionRecordEvalRequest
- func (r *SessionRecordEvalRequest) WithOwner(owner string) *SessionRecordEvalRequest
- func (r *SessionRecordEvalRequest) WithSource(source SessionSource) *SessionRecordEvalRequest
- type SessionRecordingOverrideEvalRequest
- func (r *SessionRecordingOverrideEvalRequest) Build() (*SessionRecordingOverrideEvalRequest, error)
- func (r *SessionRecordingOverrideEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SessionRecordingOverrideEvalRequest) Validate() error
- func (r *SessionRecordingOverrideEvalRequest) WithOwner(owner string) *SessionRecordingOverrideEvalRequest
- type SessionRecordingReadEvalRequest
- func (r *SessionRecordingReadEvalRequest) Build() (*SessionRecordingReadEvalRequest, error)
- func (r *SessionRecordingReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *SessionRecordingReadEvalRequest) Validate() error
- func (r *SessionRecordingReadEvalRequest) WithOwner(owner string) *SessionRecordingReadEvalRequest
- func (r *SessionRecordingReadEvalRequest) WithWorkspace(workspaceID string) *SessionRecordingReadEvalRequest
- type SessionSource
- type SessionType
- type SudoObligation
- type ThreatAction
- type ThreatDetectContext
- type ThreatDetectEvalRequest
- func (r *ThreatDetectEvalRequest) Build() (*ThreatDetectEvalRequest, error)
- func (r *ThreatDetectEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *ThreatDetectEvalRequest) Validate() error
- func (r *ThreatDetectEvalRequest) WithBlueprintName(name string) *ThreatDetectEvalRequest
- func (r *ThreatDetectEvalRequest) WithMode(mode WorkspaceProvisionMode, namespace string) *ThreatDetectEvalRequest
- func (r *ThreatDetectEvalRequest) WithOwner(owner string) *ThreatDetectEvalRequest
- func (r *ThreatDetectEvalRequest) WithResources(resources map[string]map[string]any) *ThreatDetectEvalRequest
- func (r *ThreatDetectEvalRequest) WithWorkload(name, kind string) *ThreatDetectEvalRequest
- type ThreatDetectionOverrideEvalRequest
- func (r *ThreatDetectionOverrideEvalRequest) Build() (*ThreatDetectionOverrideEvalRequest, error)
- func (r *ThreatDetectionOverrideEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *ThreatDetectionOverrideEvalRequest) Validate() error
- func (r *ThreatDetectionOverrideEvalRequest) WithOwner(owner string) *ThreatDetectionOverrideEvalRequest
- type ThreatListEvalRequest
- 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) WithIDP(idp string) *UserAuthEvalRequest
- func (r *UserAuthEvalRequest) WithOrg(org string) *UserAuthEvalRequest
- func (r *UserAuthEvalRequest) WithSurface(surface AuthSurface) *UserAuthEvalRequest
- type UserAuthMethod
- type UserClaims
- type UserCreateEvalRequest
- type UserCredentialContext
- type UserCredentialType
- type UserDataType
- type UserDeleteEvalRequest
- type UserExistsEvalRequest
- type UserExistsField
- type UserListEvalRequest
- type UserReadEvalRequest
- func (r *UserReadEvalRequest) Build() (*UserReadEvalRequest, error)
- func (r *UserReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *UserReadEvalRequest) Validate() error
- func (r *UserReadEvalRequest) WithCredentialType(t UserCredentialType) *UserReadEvalRequest
- func (r *UserReadEvalRequest) WithDataType(dt UserDataType) *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 UserTokenDeleteEvalRequest
- type UserTokenReadEvalRequest
- type UserTokenWriteEvalRequest
- type UserWriteEvalRequest
- func (r *UserWriteEvalRequest) Build() (*UserWriteEvalRequest, error)
- func (r *UserWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *UserWriteEvalRequest) Validate() error
- func (r *UserWriteEvalRequest) WithCredentialType(t UserCredentialType) *UserWriteEvalRequest
- func (r *UserWriteEvalRequest) WithDataType(dt UserDataType) *UserWriteEvalRequest
- type UsernameObligation
- 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) WithType(t WorkspaceConnectType) *WorkspaceConnectEvalRequest
- type WorkspaceConnectType
- type WorkspaceDataType
- 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) WithSource(source WorkspaceProvisionSource) *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 WorkspaceOwnerContext
- type WorkspaceOwnerEvalRequest
- func (r *WorkspaceOwnerEvalRequest) Build() (*WorkspaceOwnerEvalRequest, error)
- func (r *WorkspaceOwnerEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceOwnerEvalRequest) Validate() error
- func (r *WorkspaceOwnerEvalRequest) WithMode(mode WorkspaceProvisionMode) *WorkspaceOwnerEvalRequest
- func (r *WorkspaceOwnerEvalRequest) WithSource(source WorkspaceProvisionSource) *WorkspaceOwnerEvalRequest
- type WorkspaceProvisionContext
- type WorkspaceProvisionMode
- type WorkspaceProvisionSource
- type WorkspaceResource
- type WorkspaceUpdateEvalRequest
- func (r *WorkspaceUpdateEvalRequest) Build() (*WorkspaceUpdateEvalRequest, error)
- func (r *WorkspaceUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
- func (r *WorkspaceUpdateEvalRequest) Validate() error
- func (r *WorkspaceUpdateEvalRequest) WithDataType(dt WorkspaceDataType) *WorkspaceUpdateEvalRequest
- func (r *WorkspaceUpdateEvalRequest) WithOwner(owner string) *WorkspaceUpdateEvalRequest
Constants ¶
const ( // ObligationKeyGlobalRoles is the key the policy engine writes on a // role:list decision to indicate whether the caller may see global // (org-less) roles alongside the org-scoped ones. Independent of the // "org" obligation. ObligationKeyGlobalRoles = "global_roles" // ObligationGlobalRolesTrue is the obligation value that grants // visibility into global roles. ObligationGlobalRolesTrue = "true" // ObligationGlobalRolesFalse is the obligation value that explicitly // denies visibility into global roles. ObligationGlobalRolesFalse = "false" )
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" // ObligationRecordVscodeTerminals records VS Code integrated terminals // carried by direct-tcpip port-forwards. ObligationRecordVscodeTerminals = "vscode-terminals" // ObligationRecordVscodeInput also records those terminals' keystrokes; // it implies ObligationRecordVscodeTerminals. ObligationRecordVscodeInput = "vscode-input" )
const ( // ObligationKeyDetect is the key the policy engine writes for // threat:detect: which categories worktrace watches on the workspace. ObligationKeyDetect = "detect" // ObligationDetectNone disables detection on the workspace. ObligationDetectNone = "none" // ObligationDetectAll enables every category, including ones added after // the decision was made. ObligationDetectAll = "all" )
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 admin-driven creation. 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 ( // ObligationKeyAuthMethods is the key the policy engine writes to indicate // which authentication methods are available to the user for the surface // named in the request context. The value is a JSON-encoded array of method // strings (e.g. ["publickey","password"] for ssh, ["sso","password"] for // web). ObligationKeyAuthMethods = "auth_methods" )
const ( // ObligationKeyBlueprints is the key the policy engine writes to assign // allowed blueprints during admin-driven creation. The value is a // comma-separated list of blueprint names; "*" grants access to all // blueprints. ObligationKeyBlueprints = "blueprints" )
const ( // ObligationKeyOrg is the key the policy engine writes to scope a user:list // result to a single organization. The value is an organization name. ObligationKeyOrg = "org" )
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 admin-driven creation. The value is a JSON-encoded array of role // name strings. ObligationKeyRoles = "roles" )
const ( // ObligationKeyUsername is the key the policy engine writes to scope a // session:list result to a single session owner. The value is a username. ObligationKeyUsername = "username" )
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 ¶
func ScopeAllows(scopes []string, action string, satisfied ...ScopeConstraint) bool
ScopeAllows reports whether any scope in the list permits action. satisfied lists the constraints the caller has determined the current request meets (e.g. pass ScopeConstraintSelf when resource.id == subject.username) — the scope layer has no resource awareness of its own, so this is how a caller tells it "self" applies here.
Matching rules (strict):
- "*" matches any action
- "prefix:*" matches any action that starts with "prefix:"
- an exact scope matches only when scope == action
- a scope with a trailing ":constraint" additionally requires that constraint to be present in satisfied; an unconstrained scope matches regardless of satisfied, so a token holding the broad "user:read:profile" scope still covers its own profile
func ValidateDetectObligation ¶ added in v0.63.2
ValidateDetectObligation checks a "detect" value strictly, for enforcers that accept one from a user rather than from the policy engine: every comma-separated token must be a known category, at least one must be given, and "none" or "all" must stand alone. ParseDetectObligation itself keeps unknown categories.
func ValidateRecordObligation ¶ added in v0.62.8
ValidateRecordObligation checks a "record" obligation value strictly, for enforcers that accept one from a user rather than from the policy engine: every comma-separated token must be known, at least one must be given, and "none" must stand alone. ParseRecordObligation itself ignores unknown tokens.
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 ":*"
- any of the above (except the bare wildcard) followed by ":constraint", provided the "domain:action" prefix accepts a constraint suffix
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 AnnouncementResource ¶ added in v0.57.0
type AnnouncementResource struct {
// ID is the announcement's id, as a decimal string (resource.id in the
// EvaluateRequest). Empty for announcement:write checks that precede a
// create, where no id exists yet.
ID string
// Orgs names the organizations the announcement applies (or would
// apply) to (resource.attributes["orgs"], comma-separated). Empty means
// global. See the announcement:write contract doc for whether this is
// the requested or the current scope.
Orgs []string
// Roles names the roles the announcement is (or would be) further
// scoped to (resource.attributes["roles"], comma-separated). Empty
// means every role. See the announcement:write contract doc for
// whether this is the requested or the current scope.
Roles []string
}
AnnouncementResource holds the resource-scoped attributes for an announcement policy check.
type AnnouncementWriteEvalRequest ¶ added in v0.57.0
type AnnouncementWriteEvalRequest struct {
Resource AnnouncementResource
}
AnnouncementWriteEvalRequest is the validated, typed model for announcement:write policy evaluation — creating, updating, or deleting a platform announcement. Use NewAnnouncementWriteEvalRequest to start building, then call Build to get a validated instance.
func AnnouncementWriteEvalRequestFromProto ¶ added in v0.57.0
func AnnouncementWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*AnnouncementWriteEvalRequest, error)
AnnouncementWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated AnnouncementWriteEvalRequest.
func NewAnnouncementWriteEvalRequest ¶ added in v0.57.0
func NewAnnouncementWriteEvalRequest(id string) *AnnouncementWriteEvalRequest
NewAnnouncementWriteEvalRequest begins building an AnnouncementWriteEvalRequest for the given announcement id (empty when checking a create). Call WithOrgs/WithRoles to attach the announcement's scope, then Build to validate and obtain the final struct.
func (*AnnouncementWriteEvalRequest) Build ¶ added in v0.57.0
func (r *AnnouncementWriteEvalRequest) Build() (*AnnouncementWriteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*AnnouncementWriteEvalRequest) ToProto ¶ added in v0.57.0
func (r *AnnouncementWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*AnnouncementWriteEvalRequest) Validate ¶ added in v0.57.0
func (r *AnnouncementWriteEvalRequest) Validate() error
Validate is a no-op for announcement:write — id, orgs, and roles are all optional (empty ahead of a create, or for a global/every-role announcement, is expected). Implements EvalRequest.
func (*AnnouncementWriteEvalRequest) WithOrgs ¶ added in v0.57.0
func (r *AnnouncementWriteEvalRequest) WithOrgs(orgs []string) *AnnouncementWriteEvalRequest
WithOrgs sets the organizations the announcement applies (or would apply) to; omit (or pass nil/empty) for a global announcement.
func (*AnnouncementWriteEvalRequest) WithRoles ¶ added in v0.57.0
func (r *AnnouncementWriteEvalRequest) WithRoles(roles []string) *AnnouncementWriteEvalRequest
WithRoles sets the roles the announcement is (or would be) further scoped to; omit (or pass nil/empty) for every role.
type AuditListEvalRequest ¶ added in v0.39.0
type AuditListEvalRequest struct{}
AuditListEvalRequest is the validated, typed model for audit:list policy evaluation. No resource id is required; the subject claims determine access.
func AuditListEvalRequestFromProto ¶ added in v0.39.0
func AuditListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*AuditListEvalRequest, error)
AuditListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated AuditListEvalRequest.
func NewAuditListEvalRequest ¶ added in v0.39.0
func NewAuditListEvalRequest() *AuditListEvalRequest
NewAuditListEvalRequest returns an AuditListEvalRequest ready to be built.
func (*AuditListEvalRequest) Build ¶ added in v0.39.0
func (r *AuditListEvalRequest) Build() (*AuditListEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*AuditListEvalRequest) ToProto ¶ added in v0.39.0
func (r *AuditListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*AuditListEvalRequest) Validate ¶ added in v0.39.0
func (r *AuditListEvalRequest) Validate() error
Validate is a no-op for audit:list; no fields are required. Implements EvalRequest.
type AuthMethodsObligation ¶ added in v0.30.9
type AuthMethodsObligation struct {
// Methods is the list of authentication methods the policy permits for
// the user (any of UserAuthMethodPublicKey, UserAuthMethodPassword,
// UserAuthMethodSSO).
Methods []UserAuthMethod
}
AuthMethodsObligation is the typed representation of the "auth_methods" obligation key returned by the policy engine in a PolicyResult for user:auth.
func ParseAuthMethodsObligation ¶ added in v0.30.9
func ParseAuthMethodsObligation(obligations map[string]string) (AuthMethodsObligation, bool)
ParseAuthMethodsObligation reads the "auth_methods" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set an auth_methods obligation — in that case the enforcer should offer no authentication methods.
type AuthSurface ¶ added in v0.32.1
type AuthSurface string
AuthSurface identifies which login surface a user:auth check is evaluating. publickey is only meaningful for AuthSurfaceSSH and sso only for AuthSurfaceWeb; password is valid on either. The contract does not enforce these pairings — the enforcer for each surface ignores methods it cannot use.
const ( AuthSurfaceSSH AuthSurface = "ssh" AuthSurfaceWeb AuthSurface = "web" )
type BlueprintReadEvalRequest ¶ added in v0.36.0
type BlueprintReadEvalRequest struct{}
BlueprintReadEvalRequest is the validated, typed model for blueprints:read policy evaluation. No resource id is required; the subject claims determine access.
func BlueprintReadEvalRequestFromProto ¶ added in v0.36.0
func BlueprintReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*BlueprintReadEvalRequest, error)
BlueprintReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated BlueprintReadEvalRequest.
func NewBlueprintReadEvalRequest ¶ added in v0.36.0
func NewBlueprintReadEvalRequest() *BlueprintReadEvalRequest
NewBlueprintReadEvalRequest returns a BlueprintReadEvalRequest ready to be built.
func (*BlueprintReadEvalRequest) Build ¶ added in v0.36.0
func (r *BlueprintReadEvalRequest) Build() (*BlueprintReadEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*BlueprintReadEvalRequest) ToProto ¶ added in v0.36.0
func (r *BlueprintReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*BlueprintReadEvalRequest) Validate ¶ added in v0.36.0
func (r *BlueprintReadEvalRequest) Validate() error
Validate is a no-op for blueprints:read; no fields are required. Implements EvalRequest.
type BlueprintWriteEvalRequest ¶ added in v0.49.0
type BlueprintWriteEvalRequest struct{}
BlueprintWriteEvalRequest is the validated, typed model for blueprints:write policy evaluation — creating, updating, or deleting org-scoped blueprints. Like blueprints:read it carries no resource id; the subject claims determine access.
func BlueprintWriteEvalRequestFromProto ¶ added in v0.49.0
func BlueprintWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*BlueprintWriteEvalRequest, error)
BlueprintWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated BlueprintWriteEvalRequest.
func NewBlueprintWriteEvalRequest ¶ added in v0.49.0
func NewBlueprintWriteEvalRequest() *BlueprintWriteEvalRequest
NewBlueprintWriteEvalRequest returns a BlueprintWriteEvalRequest ready to be built.
func (*BlueprintWriteEvalRequest) Build ¶ added in v0.49.0
func (r *BlueprintWriteEvalRequest) Build() (*BlueprintWriteEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*BlueprintWriteEvalRequest) ToProto ¶ added in v0.49.0
func (r *BlueprintWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*BlueprintWriteEvalRequest) Validate ¶ added in v0.49.0
func (r *BlueprintWriteEvalRequest) Validate() error
Validate is a no-op for blueprints:write; no fields are required. Implements EvalRequest.
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:create.
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 CapabilityCheck ¶ added in v0.32.1
type CapabilityCheck struct {
// Action is the display action label, e.g. "workspace:connect:webshell".
// Matches the literal action string except for compound actions where the
// qualifier (connect type, app op, data type, auth surface) is folded in,
// mirroring the PAT scope convention in scope.go.
Action string
// Package is the OPA policy package this action is evaluated under.
Package string
// Scope is the PAT token_scopes string that caps this action, in the same
// "domain:action[:qualifier]" form ScopeAllows expects.
Scope string
// SelfOnly marks an action whose contract only makes sense when the
// subject is the resource itself — user:auth (you can only authenticate
// as yourself). Callers building a report for a resource owner other than
// the subject should skip SelfOnly checks entirely: there is no honest
// answer to "can Z authenticate as X" for Z != X.
SelfOnly bool
// Build constructs the representative EvalRequest for this action from
// ctx. It may return an error when required data isn't available in
// ctx — callers should treat that as "unevaluated", not "denied".
Build func(ctx CapabilityContext) (EvalRequest, error)
}
CapabilityCheck is a self-describing, representative probe for one authz action: enough metadata to build a syntactically valid (if synthetic) EvalRequest for a "what can I do" report, without needing a real resource to exist.
func CapabilityChecks ¶ added in v0.32.1
func CapabilityChecks() []CapabilityCheck
CapabilityChecks returns every registered capability probe. The slice is a copy; callers may filter/reorder freely without affecting the registry.
type CapabilityContext ¶ added in v0.32.1
type CapabilityContext struct {
// ResourceOwner is the username whose resources the check is scoped to —
// workspace/session/ssh owner, or the target user record itself.
ResourceOwner string
// IDP and Org are ResourceOwner's real identity source and organization,
// required by user:auth, and used by user:create/delete.
// Leave empty when unknown (e.g. ResourceOwner doesn't exist yet) — the
// affected Build funcs then fail Validate() and the check is reported as
// unevaluated rather than answered against a fabricated identity.
IDP, Org string
// BlueprintName and Blueprint feed workspace:provision. BlueprintName
// empty means "not supplied" — Build leaves the request's required
// blueprint context unset on purpose, so Validate() fails and the check
// comes back unevaluated rather than silently denied.
BlueprintName string
Blueprint *models.Blueprint
}
CapabilityContext carries every synthetic/representative value a capability probe might need to build a syntactically valid EvalRequest without a real resource existing. Not every action uses every field — each CapabilityCheck.Build pulls only what its contract requires.
type DetectObligation ¶ added in v0.63.2
type DetectObligation struct {
// All enables every category; Categories is then empty.
All bool
// Categories lists the enabled categories when All is false, in the order
// given. It may hold categories this module does not know yet.
Categories []threat.Category
}
DetectObligation is the typed representation of the "detect" obligation. The zero value detects nothing.
func ParseDetectObligation ¶ added in v0.63.2
func ParseDetectObligation(obligations map[string]string) (DetectObligation, bool)
ParseDetectObligation reads the "detect" key from the obligations map. The value is "none", "all", or comma-separated categories; "all" anywhere wins, and empty and duplicate tokens are dropped. Unknown categories are kept, so a category worktrace adds before this module knows it still applies. Returns (obligation, true) when the key is present, (zero, false) when the policy set no detect obligation — the enforcer then applies its default.
func (DetectObligation) Includes ¶ added in v0.63.2
func (o DetectObligation) Includes(c threat.Category) bool
Includes reports whether category c is detected.
func (DetectObligation) None ¶ added in v0.63.2
func (o DetectObligation) None() bool
None reports whether nothing is detected.
func (DetectObligation) String ¶ added in v0.63.2
func (o DetectObligation) String() string
String returns the obligation as a "detect" value: "all", "none", or the comma-separated categories. ParseDetectObligation reads it back.
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 GitAction ¶ added in v0.63.2
type GitAction string
GitAction is the action string of a git proxy policy check.
type GitContext ¶ added in v0.63.2
type GitContext struct {
// Workspace is the name of the workspace the request originates from
// (context["workspace"]); empty when the request isn't bound to one.
Workspace string
// WorkspaceOwner is the username of Workspace's owner
// (context["workspace_owner"]), taken from the workspace record; set
// exactly when Workspace is.
WorkspaceOwner string
}
GitContext holds the ambient context for a git policy check.
type GitEvalRequest ¶ added in v0.63.2
type GitEvalRequest struct {
Action GitAction
Resource GitResource
Context GitContext
}
GitEvalRequest is the validated, typed model for git:fetch and git:push policy evaluation. Use NewGitEvalRequest to start building, then call Build to get a validated instance.
func GitEvalRequestFromProto ¶ added in v0.63.2
func GitEvalRequestFromProto(req *authzv1.EvaluateRequest) (*GitEvalRequest, error)
GitEvalRequestFromProto converts a gRPC EvaluateRequest into a validated GitEvalRequest.
func NewGitEvalRequest ¶ added in v0.63.2
func NewGitEvalRequest(action GitAction, repo string) *GitEvalRequest
NewGitEvalRequest begins building a GitEvalRequest for the given action and normalized repository id ("host/path"). Host is derived from repo. Call WithWorkspace to attach the originating workspace and its owner, then Build to validate and obtain the final struct.
func (*GitEvalRequest) Build ¶ added in v0.63.2
func (r *GitEvalRequest) Build() (*GitEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*GitEvalRequest) ToProto ¶ added in v0.63.2
func (r *GitEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*GitEvalRequest) Validate ¶ added in v0.63.2
func (r *GitEvalRequest) Validate() error
Validate checks the request against the git:fetch/git:push contract. Implements EvalRequest.
func (*GitEvalRequest) WithWorkspace ¶ added in v0.63.2
func (r *GitEvalRequest) WithWorkspace(workspace, owner string) *GitEvalRequest
WithWorkspace sets the workspace the request originates from and its owner, as recorded on the workspace itself — not the subject's username.
type GitResource ¶ added in v0.63.2
type GitResource struct {
// Repo is the normalized repository id, "host/path" (resource.id).
Repo string
// Host is the repository host (resource.attributes["host"]), always the
// first "/"-separated segment of Repo.
Host string
}
GitResource holds the resource-scoped attributes for a git policy check.
type GlobalRolesObligation ¶ added in v0.35.0
type GlobalRolesObligation struct {
// Granted is true when the policy allows the caller to see global roles.
Granted bool
}
GlobalRolesObligation is the typed representation of the "global_roles" obligation key returned by the policy engine in a PolicyResult for role:list.
func ParseGlobalRolesObligation ¶ added in v0.35.0
func ParseGlobalRolesObligation(obligations map[string]string) (GlobalRolesObligation, bool)
ParseGlobalRolesObligation reads the "global_roles" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set it. Either way, the enforcer should treat visibility as denied unless Granted is true — the zero value already defaults to false, so callers can use Granted directly without checking the second return value.
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 OnboardRuleCreateEvalRequest ¶ added in v0.36.0
type OnboardRuleCreateEvalRequest struct {
Resource OnboardRuleResource
}
OnboardRuleCreateEvalRequest is the validated, typed model for onboardrule:create policy evaluation. Use NewOnboardRuleCreateEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
func NewOnboardRuleCreateEvalRequest ¶ added in v0.36.0
func NewOnboardRuleCreateEvalRequest(usernamePattern string) *OnboardRuleCreateEvalRequest
NewOnboardRuleCreateEvalRequest begins building an OnboardRuleCreateEvalRequest for the given proposed username pattern. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func OnboardRuleCreateEvalRequestFromProto ¶ added in v0.36.0
func OnboardRuleCreateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OnboardRuleCreateEvalRequest, error)
OnboardRuleCreateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OnboardRuleCreateEvalRequest.
func (*OnboardRuleCreateEvalRequest) Build ¶ added in v0.36.0
func (r *OnboardRuleCreateEvalRequest) Build() (*OnboardRuleCreateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OnboardRuleCreateEvalRequest) ToProto ¶ added in v0.36.0
func (r *OnboardRuleCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OnboardRuleCreateEvalRequest) Validate ¶ added in v0.36.0
func (r *OnboardRuleCreateEvalRequest) Validate() error
Validate checks the request against the onboardrule:create contract. Implements EvalRequest.
func (*OnboardRuleCreateEvalRequest) WithIDP ¶ added in v0.36.0
func (r *OnboardRuleCreateEvalRequest) WithIDP(idp string) *OnboardRuleCreateEvalRequest
WithIDP sets the identity provider the new rule applies to.
func (*OnboardRuleCreateEvalRequest) WithOrg ¶ added in v0.36.0
func (r *OnboardRuleCreateEvalRequest) WithOrg(org string) *OnboardRuleCreateEvalRequest
WithOrg sets the organization the new rule will be scoped to.
type OnboardRuleDeleteEvalRequest ¶ added in v0.36.0
type OnboardRuleDeleteEvalRequest struct {
Resource OnboardRuleResource
}
OnboardRuleDeleteEvalRequest is the validated, typed model for onboardrule:delete policy evaluation. Use NewOnboardRuleDeleteEvalRequest to start building, then chain WithOrg and call Build to get a validated instance.
func NewOnboardRuleDeleteEvalRequest ¶ added in v0.36.0
func NewOnboardRuleDeleteEvalRequest(id string) *OnboardRuleDeleteEvalRequest
NewOnboardRuleDeleteEvalRequest begins building an OnboardRuleDeleteEvalRequest for the given rule id (as a decimal string). Chain WithOrg to supply the rule's organization, then call Build to validate and obtain the final struct.
func OnboardRuleDeleteEvalRequestFromProto ¶ added in v0.36.0
func OnboardRuleDeleteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OnboardRuleDeleteEvalRequest, error)
OnboardRuleDeleteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OnboardRuleDeleteEvalRequest.
func (*OnboardRuleDeleteEvalRequest) Build ¶ added in v0.36.0
func (r *OnboardRuleDeleteEvalRequest) Build() (*OnboardRuleDeleteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OnboardRuleDeleteEvalRequest) ToProto ¶ added in v0.36.0
func (r *OnboardRuleDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OnboardRuleDeleteEvalRequest) Validate ¶ added in v0.36.0
func (r *OnboardRuleDeleteEvalRequest) Validate() error
Validate checks the request against the onboardrule:delete contract. Implements EvalRequest.
func (*OnboardRuleDeleteEvalRequest) WithOrg ¶ added in v0.36.0
func (r *OnboardRuleDeleteEvalRequest) WithOrg(org string) *OnboardRuleDeleteEvalRequest
WithOrg sets the organization the rule being deleted is scoped to.
type OnboardRuleListEvalRequest ¶ added in v0.36.0
type OnboardRuleListEvalRequest struct {
Resource OnboardRuleResource
}
OnboardRuleListEvalRequest is the validated, typed model for onboardrule:list policy evaluation. Use NewOnboardRuleListEvalRequest to start building, then call Build to get a validated instance.
func NewOnboardRuleListEvalRequest ¶ added in v0.36.0
func NewOnboardRuleListEvalRequest(org string) *OnboardRuleListEvalRequest
NewOnboardRuleListEvalRequest begins building an OnboardRuleListEvalRequest for the given organization. Call Build to validate and obtain the final struct.
func OnboardRuleListEvalRequestFromProto ¶ added in v0.36.0
func OnboardRuleListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OnboardRuleListEvalRequest, error)
OnboardRuleListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OnboardRuleListEvalRequest.
func (*OnboardRuleListEvalRequest) Build ¶ added in v0.36.0
func (r *OnboardRuleListEvalRequest) Build() (*OnboardRuleListEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OnboardRuleListEvalRequest) ToProto ¶ added in v0.36.0
func (r *OnboardRuleListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OnboardRuleListEvalRequest) Validate ¶ added in v0.36.0
func (r *OnboardRuleListEvalRequest) Validate() error
Validate checks the request against the onboardrule:list contract. Implements EvalRequest.
type OnboardRuleResource ¶ added in v0.36.0
type OnboardRuleResource struct {
// ID is the resource id (resource.id in the EvaluateRequest) — the
// rule's numeric id (as a decimal string) for update/delete, or the
// proposed username pattern for create, where no id exists yet.
ID string
// Org is the organization the rule is (or will be) scoped to
// (resource.attributes["org"]). Always required.
Org string
// IDP is the identity provider the rule applies to
// (resource.attributes["idp"]). Only set for onboardrule:create.
IDP string
}
OnboardRuleResource holds the resource-scoped attributes for an onboard rule policy check.
type OnboardRuleUpdateEvalRequest ¶ added in v0.36.0
type OnboardRuleUpdateEvalRequest struct {
Resource OnboardRuleResource
}
OnboardRuleUpdateEvalRequest is the validated, typed model for onboardrule:update policy evaluation. Use NewOnboardRuleUpdateEvalRequest to start building, then chain WithOrg and call Build to get a validated instance.
func NewOnboardRuleUpdateEvalRequest ¶ added in v0.36.0
func NewOnboardRuleUpdateEvalRequest(id string) *OnboardRuleUpdateEvalRequest
NewOnboardRuleUpdateEvalRequest begins building an OnboardRuleUpdateEvalRequest for the given rule id (as a decimal string). Chain WithOrg to supply the rule's organization, then call Build to validate and obtain the final struct.
func OnboardRuleUpdateEvalRequestFromProto ¶ added in v0.36.0
func OnboardRuleUpdateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OnboardRuleUpdateEvalRequest, error)
OnboardRuleUpdateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OnboardRuleUpdateEvalRequest.
func (*OnboardRuleUpdateEvalRequest) Build ¶ added in v0.36.0
func (r *OnboardRuleUpdateEvalRequest) Build() (*OnboardRuleUpdateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OnboardRuleUpdateEvalRequest) ToProto ¶ added in v0.36.0
func (r *OnboardRuleUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OnboardRuleUpdateEvalRequest) Validate ¶ added in v0.36.0
func (r *OnboardRuleUpdateEvalRequest) Validate() error
Validate checks the request against the onboardrule:update contract. Implements EvalRequest.
func (*OnboardRuleUpdateEvalRequest) WithOrg ¶ added in v0.36.0
func (r *OnboardRuleUpdateEvalRequest) WithOrg(org string) *OnboardRuleUpdateEvalRequest
WithOrg sets the organization the rule being updated is scoped to.
type OrgObligation ¶ added in v0.30.6
type OrgObligation struct {
// Org is the organization the enforcer should restrict the listing to.
Org string
}
OrgObligation is the typed representation of the "org" obligation key returned by the policy engine in a PolicyResult for user:list.
func ParseOrgObligation ¶ added in v0.30.6
func ParseOrgObligation(obligations map[string]string) (OrgObligation, bool)
ParseOrgObligation reads the "org" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set an org obligation — in that case the enforcer should not scope the listing by organization.
type OrganizationCreateEvalRequest ¶ added in v0.35.0
type OrganizationCreateEvalRequest struct {
Resource OrganizationResource
}
OrganizationCreateEvalRequest is the validated, typed model for org:create policy evaluation. Use NewOrganizationCreateEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationCreateEvalRequest ¶ added in v0.35.0
func NewOrganizationCreateEvalRequest(name string) *OrganizationCreateEvalRequest
NewOrganizationCreateEvalRequest begins building an OrganizationCreateEvalRequest for the given proposed organization name. Call Build to validate and obtain the final struct.
func OrganizationCreateEvalRequestFromProto ¶ added in v0.35.0
func OrganizationCreateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationCreateEvalRequest, error)
OrganizationCreateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationCreateEvalRequest.
func (*OrganizationCreateEvalRequest) Build ¶ added in v0.35.0
func (r *OrganizationCreateEvalRequest) Build() (*OrganizationCreateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationCreateEvalRequest) ToProto ¶ added in v0.35.0
func (r *OrganizationCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationCreateEvalRequest) Validate ¶ added in v0.35.0
func (r *OrganizationCreateEvalRequest) Validate() error
Validate checks the request against the org:create contract. Implements EvalRequest.
type OrganizationDeleteEvalRequest ¶ added in v0.35.0
type OrganizationDeleteEvalRequest struct {
Resource OrganizationResource
}
OrganizationDeleteEvalRequest is the validated, typed model for org:delete policy evaluation. Use NewOrganizationDeleteEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationDeleteEvalRequest ¶ added in v0.35.0
func NewOrganizationDeleteEvalRequest(name string) *OrganizationDeleteEvalRequest
NewOrganizationDeleteEvalRequest begins building an OrganizationDeleteEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationDeleteEvalRequestFromProto ¶ added in v0.35.0
func OrganizationDeleteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationDeleteEvalRequest, error)
OrganizationDeleteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationDeleteEvalRequest.
func (*OrganizationDeleteEvalRequest) Build ¶ added in v0.35.0
func (r *OrganizationDeleteEvalRequest) Build() (*OrganizationDeleteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationDeleteEvalRequest) ToProto ¶ added in v0.35.0
func (r *OrganizationDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationDeleteEvalRequest) Validate ¶ added in v0.35.0
func (r *OrganizationDeleteEvalRequest) Validate() error
Validate checks the request against the org:delete contract. Implements EvalRequest.
type OrganizationEnvVarReadEvalRequest ¶ added in v0.46.0
type OrganizationEnvVarReadEvalRequest struct {
Resource OrganizationResource
}
OrganizationEnvVarReadEvalRequest is the validated, typed model for org:envvar:read policy evaluation — listing or reading an organization's environment variables. Use NewOrganizationEnvVarReadEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationEnvVarReadEvalRequest ¶ added in v0.46.0
func NewOrganizationEnvVarReadEvalRequest(name string) *OrganizationEnvVarReadEvalRequest
NewOrganizationEnvVarReadEvalRequest begins building an OrganizationEnvVarReadEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationEnvVarReadEvalRequestFromProto ¶ added in v0.46.0
func OrganizationEnvVarReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationEnvVarReadEvalRequest, error)
OrganizationEnvVarReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationEnvVarReadEvalRequest.
func (*OrganizationEnvVarReadEvalRequest) Build ¶ added in v0.46.0
func (r *OrganizationEnvVarReadEvalRequest) Build() (*OrganizationEnvVarReadEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationEnvVarReadEvalRequest) ToProto ¶ added in v0.46.0
func (r *OrganizationEnvVarReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationEnvVarReadEvalRequest) Validate ¶ added in v0.46.0
func (r *OrganizationEnvVarReadEvalRequest) Validate() error
Validate checks the request against the org:envvar:read contract. Implements EvalRequest.
type OrganizationEnvVarWriteEvalRequest ¶ added in v0.46.0
type OrganizationEnvVarWriteEvalRequest struct {
Resource OrganizationResource
}
OrganizationEnvVarWriteEvalRequest is the validated, typed model for org:envvar:write policy evaluation — adding, updating, or deleting an organization's environment variables. Use NewOrganizationEnvVarWriteEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationEnvVarWriteEvalRequest ¶ added in v0.46.0
func NewOrganizationEnvVarWriteEvalRequest(name string) *OrganizationEnvVarWriteEvalRequest
NewOrganizationEnvVarWriteEvalRequest begins building an OrganizationEnvVarWriteEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationEnvVarWriteEvalRequestFromProto ¶ added in v0.46.0
func OrganizationEnvVarWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationEnvVarWriteEvalRequest, error)
OrganizationEnvVarWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationEnvVarWriteEvalRequest.
func (*OrganizationEnvVarWriteEvalRequest) Build ¶ added in v0.46.0
func (r *OrganizationEnvVarWriteEvalRequest) Build() (*OrganizationEnvVarWriteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationEnvVarWriteEvalRequest) ToProto ¶ added in v0.46.0
func (r *OrganizationEnvVarWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationEnvVarWriteEvalRequest) Validate ¶ added in v0.46.0
func (r *OrganizationEnvVarWriteEvalRequest) Validate() error
Validate checks the request against the org:envvar:write contract. Implements EvalRequest.
type OrganizationListEvalRequest ¶ added in v0.35.0
type OrganizationListEvalRequest struct{}
OrganizationListEvalRequest is the validated, typed model for org:list policy evaluation. No resource id is required; the subject claims determine access.
func NewOrganizationListEvalRequest ¶ added in v0.35.0
func NewOrganizationListEvalRequest() *OrganizationListEvalRequest
NewOrganizationListEvalRequest returns an OrganizationListEvalRequest ready to be built.
func OrganizationListEvalRequestFromProto ¶ added in v0.35.0
func OrganizationListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationListEvalRequest, error)
OrganizationListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationListEvalRequest.
func (*OrganizationListEvalRequest) Build ¶ added in v0.35.0
func (r *OrganizationListEvalRequest) Build() (*OrganizationListEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*OrganizationListEvalRequest) ToProto ¶ added in v0.35.0
func (r *OrganizationListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationListEvalRequest) Validate ¶ added in v0.35.0
func (r *OrganizationListEvalRequest) Validate() error
Validate is a no-op for org:list; no fields are required. Implements EvalRequest.
type OrganizationNodeWriteEvalRequest ¶ added in v0.65.4
type OrganizationNodeWriteEvalRequest struct {
Resource OrganizationResource
}
OrganizationNodeWriteEvalRequest is the validated, typed model for org:node:write policy evaluation — setting an organization's node selectors. Use NewOrganizationNodeWriteEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationNodeWriteEvalRequest ¶ added in v0.65.4
func NewOrganizationNodeWriteEvalRequest(name string) *OrganizationNodeWriteEvalRequest
NewOrganizationNodeWriteEvalRequest begins building an OrganizationNodeWriteEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationNodeWriteEvalRequestFromProto ¶ added in v0.65.4
func OrganizationNodeWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationNodeWriteEvalRequest, error)
OrganizationNodeWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationNodeWriteEvalRequest.
func (*OrganizationNodeWriteEvalRequest) Build ¶ added in v0.65.4
func (r *OrganizationNodeWriteEvalRequest) Build() (*OrganizationNodeWriteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationNodeWriteEvalRequest) ToProto ¶ added in v0.65.4
func (r *OrganizationNodeWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationNodeWriteEvalRequest) Validate ¶ added in v0.65.4
func (r *OrganizationNodeWriteEvalRequest) Validate() error
Validate checks the request against the org:node:write contract. Implements EvalRequest.
type OrganizationReadEvalRequest ¶ added in v0.36.0
type OrganizationReadEvalRequest struct {
Resource OrganizationResource
}
OrganizationReadEvalRequest is the validated, typed model for org:read policy evaluation. Use NewOrganizationReadEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationReadEvalRequest ¶ added in v0.36.0
func NewOrganizationReadEvalRequest(name string) *OrganizationReadEvalRequest
NewOrganizationReadEvalRequest begins building an OrganizationReadEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationReadEvalRequestFromProto ¶ added in v0.36.0
func OrganizationReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationReadEvalRequest, error)
OrganizationReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationReadEvalRequest.
func (*OrganizationReadEvalRequest) Build ¶ added in v0.36.0
func (r *OrganizationReadEvalRequest) Build() (*OrganizationReadEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationReadEvalRequest) ToProto ¶ added in v0.36.0
func (r *OrganizationReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationReadEvalRequest) Validate ¶ added in v0.36.0
func (r *OrganizationReadEvalRequest) Validate() error
Validate checks the request against the org:read contract. Implements EvalRequest.
type OrganizationResource ¶ added in v0.35.0
type OrganizationResource struct {
// ID is the organization name (resource.id in the EvaluateRequest).
ID string
}
OrganizationResource holds the resource-scoped attributes for an organization policy check.
type OrganizationUpdateEvalRequest ¶ added in v0.35.0
type OrganizationUpdateEvalRequest struct {
Resource OrganizationResource
}
OrganizationUpdateEvalRequest is the validated, typed model for org:update policy evaluation. Use NewOrganizationUpdateEvalRequest to start building, then call Build to get a validated instance.
func NewOrganizationUpdateEvalRequest ¶ added in v0.35.0
func NewOrganizationUpdateEvalRequest(name string) *OrganizationUpdateEvalRequest
NewOrganizationUpdateEvalRequest begins building an OrganizationUpdateEvalRequest for the given organization name. Call Build to validate and obtain the final struct.
func OrganizationUpdateEvalRequestFromProto ¶ added in v0.35.0
func OrganizationUpdateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*OrganizationUpdateEvalRequest, error)
OrganizationUpdateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated OrganizationUpdateEvalRequest.
func (*OrganizationUpdateEvalRequest) Build ¶ added in v0.35.0
func (r *OrganizationUpdateEvalRequest) Build() (*OrganizationUpdateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*OrganizationUpdateEvalRequest) ToProto ¶ added in v0.35.0
func (r *OrganizationUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*OrganizationUpdateEvalRequest) Validate ¶ added in v0.35.0
func (r *OrganizationUpdateEvalRequest) Validate() error
Validate checks the request against the org:update contract. Implements EvalRequest.
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"]
// Scope is the compound "domain:action[:qualifier]" display form of
// Action for actions whose qualifier (auth surface, credential type,
// connect type, ...) is folded in for display — the same convention
// CapabilityCheck.Action uses for the synthetic probe registry (see
// capability.go), computed here from this request's actual context
// instead of a fixed representative value. Equal to Action for actions
// with no such qualifier.
//
// This is a display/audit convenience only — it must never be used for
// policy routing or PAT scope matching, both of which stay keyed on the
// base Action. The two can legitimately diverge: workspace:create's PAT
// Scope stays "workspace:create" regardless of provision mode (a token
// scoped for it may create either), while Scope here still distinguishes
// "workspace:create:inject" from "workspace:create:standalone" so a
// capability listing or audit trail can show which was actually used.
Scope string
// CapabilityCheck marks this evaluation as a synthetic "what can I do"
// probe rather than a real access attempt. It is not set by
// BuildPolicyInput — since capability_check is a BatchEvaluateRequest-level
// flag, the caller of BatchEvaluate must propagate it onto each request's
// PolicyInput after construction. Policy-decision audit logging should
// record and classify these separately from genuine authorization
// decisions.
CapabilityCheck bool
}
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 ¶
type RecordObligation struct {
Shell bool
Exec bool
DirectTCPIP bool
SFTP bool
// VscodeTerminals records VS Code integrated terminals in port-forwards,
// as their own recordings. It is independent of DirectTCPIP: without it
// the port-forward's raw data is not stored.
VscodeTerminals bool
// VscodeInput includes keystrokes in the VS Code terminal recordings.
// When set, VscodeTerminals is set too.
VscodeInput bool
}
RecordObligation is the typed representation of the "record" obligation key returned by the policy engine in a PolicyResult for session:record. Each field corresponds to one obligation token; 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 tokens ("shell", "exec", "direct-tcpip", "sftp", "vscode-terminals", "vscode-input"); "none" or an unrecognised value leaves all fields false. "vscode-input" implies "vscode-terminals". 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).
func (RecordObligation) RecordsTCPIP ¶ added in v0.62.6
func (o RecordObligation) RecordsTCPIP() bool
RecordsTCPIP reports whether a direct-tcpip port-forward must be recorded, for its raw data or for the VS Code terminals it carries.
func (RecordObligation) Tokens ¶ added in v0.62.8
func (o RecordObligation) Tokens() []string
Tokens returns the obligation's set fields as "record" tokens, in the order shell, exec, direct-tcpip, sftp, vscode-terminals, vscode-input. A zero obligation (nothing recorded) yields an empty, non-nil slice.
type RoleCreateEvalRequest ¶ added in v0.35.0
type RoleCreateEvalRequest struct {
Resource RoleResource
}
RoleCreateEvalRequest is the validated, typed model for role:create policy evaluation. Use NewRoleCreateEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
func NewRoleCreateEvalRequest ¶ added in v0.35.0
func NewRoleCreateEvalRequest(name string) *RoleCreateEvalRequest
NewRoleCreateEvalRequest begins building a RoleCreateEvalRequest for the given proposed role name. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func RoleCreateEvalRequestFromProto ¶ added in v0.35.0
func RoleCreateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*RoleCreateEvalRequest, error)
RoleCreateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated RoleCreateEvalRequest.
func (*RoleCreateEvalRequest) Build ¶ added in v0.35.0
func (r *RoleCreateEvalRequest) Build() (*RoleCreateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*RoleCreateEvalRequest) ToProto ¶ added in v0.35.0
func (r *RoleCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*RoleCreateEvalRequest) Validate ¶ added in v0.35.0
func (r *RoleCreateEvalRequest) Validate() error
Validate checks the request against the role:create contract. Implements EvalRequest.
func (*RoleCreateEvalRequest) WithOrg ¶ added in v0.35.0
func (r *RoleCreateEvalRequest) WithOrg(org string) *RoleCreateEvalRequest
WithOrg sets the organization the new role will be scoped to.
type RoleDeleteEvalRequest ¶ added in v0.35.0
type RoleDeleteEvalRequest struct {
Resource RoleResource
}
RoleDeleteEvalRequest is the validated, typed model for role:delete policy evaluation. Use NewRoleDeleteEvalRequest to start building, then call Build to get a validated instance.
func NewRoleDeleteEvalRequest ¶ added in v0.35.0
func NewRoleDeleteEvalRequest(name string) *RoleDeleteEvalRequest
NewRoleDeleteEvalRequest begins building a RoleDeleteEvalRequest for the given role name. Chain WithOrg to supply the role's organization, then call Build to validate and obtain the final struct.
func RoleDeleteEvalRequestFromProto ¶ added in v0.35.0
func RoleDeleteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*RoleDeleteEvalRequest, error)
RoleDeleteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated RoleDeleteEvalRequest.
func (*RoleDeleteEvalRequest) Build ¶ added in v0.35.0
func (r *RoleDeleteEvalRequest) Build() (*RoleDeleteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*RoleDeleteEvalRequest) ToProto ¶ added in v0.35.0
func (r *RoleDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*RoleDeleteEvalRequest) Validate ¶ added in v0.35.0
func (r *RoleDeleteEvalRequest) Validate() error
Validate checks the request against the role:delete contract. Implements EvalRequest.
func (*RoleDeleteEvalRequest) WithOrg ¶ added in v0.35.0
func (r *RoleDeleteEvalRequest) WithOrg(org string) *RoleDeleteEvalRequest
WithOrg sets the organization the role being deleted is scoped to.
type RoleListEvalRequest ¶ added in v0.35.0
type RoleListEvalRequest struct{}
RoleListEvalRequest is the validated, typed model for role:list policy evaluation. No resource id is required; the subject claims determine access.
func NewRoleListEvalRequest ¶ added in v0.35.0
func NewRoleListEvalRequest() *RoleListEvalRequest
NewRoleListEvalRequest returns a RoleListEvalRequest ready to be built.
func RoleListEvalRequestFromProto ¶ added in v0.35.0
func RoleListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*RoleListEvalRequest, error)
RoleListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated RoleListEvalRequest.
func (*RoleListEvalRequest) Build ¶ added in v0.35.0
func (r *RoleListEvalRequest) Build() (*RoleListEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*RoleListEvalRequest) ToProto ¶ added in v0.35.0
func (r *RoleListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*RoleListEvalRequest) Validate ¶ added in v0.35.0
func (r *RoleListEvalRequest) Validate() error
Validate is a no-op for role:list; no fields are required. Implements EvalRequest.
type RoleResource ¶ added in v0.35.0
type RoleResource struct {
// ID is the role name (resource.id in the EvaluateRequest).
ID string
// Org is the organization the role is scoped to (resource.attributes["org"]).
// Required; global roles cannot be created, deleted, or updated.
Org string
}
RoleResource holds the resource-scoped attributes for a role policy check. Used by role:create, role:delete, and role:update — all three require a non-empty Org, since global (org-less) roles can only ever be listed.
type RoleUpdateEvalRequest ¶ added in v0.35.0
type RoleUpdateEvalRequest struct {
Resource RoleResource
}
RoleUpdateEvalRequest is the validated, typed model for role:update policy evaluation. Use NewRoleUpdateEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
func NewRoleUpdateEvalRequest ¶ added in v0.35.0
func NewRoleUpdateEvalRequest(name string) *RoleUpdateEvalRequest
NewRoleUpdateEvalRequest begins building a RoleUpdateEvalRequest for the given role name. Chain WithOrg to supply the role's organization, then call Build to validate and obtain the final struct.
func RoleUpdateEvalRequestFromProto ¶ added in v0.35.0
func RoleUpdateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*RoleUpdateEvalRequest, error)
RoleUpdateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated RoleUpdateEvalRequest.
func (*RoleUpdateEvalRequest) Build ¶ added in v0.35.0
func (r *RoleUpdateEvalRequest) Build() (*RoleUpdateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*RoleUpdateEvalRequest) ToProto ¶ added in v0.35.0
func (r *RoleUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*RoleUpdateEvalRequest) Validate ¶ added in v0.35.0
func (r *RoleUpdateEvalRequest) Validate() error
Validate checks the request against the role:update contract. Implements EvalRequest.
func (*RoleUpdateEvalRequest) WithOrg ¶ added in v0.35.0
func (r *RoleUpdateEvalRequest) WithOrg(org string) *RoleUpdateEvalRequest
WithOrg sets the organization the role being updated is scoped to.
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:create.
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:*"), optionally narrowed by a trailing constraint (e.g. "user:read:profile:self").
Grammar:
scope = "*"
| domain ":" action
| domain ":" action ":" qualifier
| domain ":" action ":" qualifier ":" constraint
| domain ":" action ":" "*"
| domain ":" action ":" "*" ":" constraint
| 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:*").
A constraint is an additional, orthogonal condition evaluated against the request rather than the action string — it doesn't change which action the scope matches, only whether the scope applies to this particular request. A plain (unconstrained) scope keeps matching regardless of any constraint state, so a token already holding the broad "user:read:profile" scope is unaffected by a caller also being able to satisfy "self". See ScopeConstraint for the constraint vocabulary and ScopeAllows for how constraint satisfaction is supplied by the caller.
type ScopeCatalog ¶ added in v0.36.0
type ScopeCatalog struct {
Global *ScopeCatalogEntry `json:"global"`
Domains []ScopeCatalogDomain `json:"domains"`
}
ScopeCatalog is the full set of selectable PAT scopes, grouped for rendering as a checkbox tree. Global is the bare "*" scope — it grants every action across every domain and is surfaced separately since it doesn't belong to any one domain.
func ScopeCatalogDoc ¶ added in v0.36.0
func ScopeCatalogDoc() ScopeCatalog
ScopeCatalogDoc returns the full, ordered catalog of selectable PAT scopes for UI rendering and editing.
type ScopeCatalogAction ¶ added in v0.36.0
type ScopeCatalogAction struct {
Action string `json:"action"`
Label string `json:"label"`
Entries []ScopeCatalogEntry `json:"entries"`
}
ScopeCatalogAction groups the scope entries for one "domain:action" prefix, e.g. every workspace:connect:* qualifier.
type ScopeCatalogDomain ¶ added in v0.36.0
type ScopeCatalogDomain struct {
Domain string `json:"domain"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Wildcard *ScopeCatalogEntry `json:"wildcard,omitempty"`
Actions []ScopeCatalogAction `json:"actions"`
}
ScopeCatalogDomain groups all actions under one scope domain (workspace, user, token, ...). Wildcard, when non-nil, is the "domain:*" entry that grants every action in the domain at once.
type ScopeCatalogEntry ¶ added in v0.36.0
type ScopeCatalogEntry struct {
// Scope is the literal scope string to store, e.g. "workspace:connect:webshell"
// or "workspace:connect:*".
Scope string `json:"scope"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
// Wildcard is true when Scope ends in ":*" and covers every sibling
// entry in the same action group.
Wildcard bool `json:"wildcard"`
// Constraints lists the constraint suffixes this scope accepts (today,
// only "self"). A UI may offer these as a toggle that appends
// ":<constraint>" to Scope rather than exposing the raw syntax.
Constraints []string `json:"constraints,omitempty"`
}
ScopeCatalogEntry describes one selectable PAT scope for UI rendering.
type ScopeConstraint ¶ added in v0.33.0
type ScopeConstraint string
ScopeConstraint is the optional 4th segment of a scope string. It narrows a scope to requests that satisfy some condition the scope grammar alone can't express — one the caller must evaluate against the actual request and report back to ScopeAllows (e.g. "is the resource being accessed the token's own subject?"). New constraints are added to validScopeConstraints; domains opt individual domain:action prefixes into accepting a constraint suffix via scopeConstrainablePrefixes.
const ( // ScopeConstraintSelf restricts a scope to requests where the resource // being accessed belongs to the token's own subject, i.e. // resource.id == subject.username. Callers determine this themselves // (the scope layer has no resource awareness) and pass ScopeConstraintSelf // to ScopeAllows when true. ScopeConstraintSelf ScopeConstraint = "self" )
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 ( // SessionActionRecord is the action evaluated when a new session is being // established, solely to learn what to record. The policy result may carry // a "record" obligation that instructs the enforcer what kind of recording // to apply to the session; Allowed is not a gate (see the contract above). SessionActionRecord SessionAction = "session:record" // 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" // SessionActionRecordingRead is the action evaluated when reading session // recordings (listing, metadata, download, playback). It covers every // recording type; the resource fields scope it exactly as for // SessionActionList. SessionActionRecordingRead SessionAction = "session:recording:read" // SessionActionRecordingOverride is the action evaluated when reading, // setting or clearing a workspace's recording override (see // nats.RecordingOverride), which replaces the session:record obligation // for every session to that workspace. The resource is always one // workspace (id and owner set), except in a capability probe, which sets // the owner only. SessionActionRecordingOverride SessionAction = "session:recording:override" )
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 SessionRecordEvalRequest ¶ added in v0.62.3
type SessionRecordEvalRequest struct {
Action SessionAction
Resource WorkspaceResource
Context SessionContext
}
SessionRecordEvalRequest is the validated, typed model for session policy evaluation. Use NewSessionRecordEvalRequest to start building, then chain With* methods and call Build to get a validated instance. Use SessionRecordEvalRequestFromProto to convert directly from a gRPC EvaluateRequest.
func NewSessionRecordEvalRequest ¶ added in v0.62.3
func NewSessionRecordEvalRequest(action SessionAction, workspaceID string, sessionType SessionType) *SessionRecordEvalRequest
NewSessionRecordEvalRequest begins building a SessionRecordEvalRequest 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 SessionRecordEvalRequestFromProto ¶ added in v0.62.3
func SessionRecordEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SessionRecordEvalRequest, error)
SessionRecordEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SessionRecordEvalRequest. Returns an error if the request does not conform to the session policy contract.
func (*SessionRecordEvalRequest) Build ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) Build() (*SessionRecordEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*SessionRecordEvalRequest) ToProto ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) 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 (*SessionRecordEvalRequest) Validate ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) 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 (*SessionRecordEvalRequest) WithBlueprint ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) WithBlueprint(blueprint string) *SessionRecordEvalRequest
WithBlueprint sets the blueprint name on the resource.
func (*SessionRecordEvalRequest) WithOwner ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) WithOwner(owner string) *SessionRecordEvalRequest
WithOwner sets the workspace owner on the resource.
func (*SessionRecordEvalRequest) WithSource ¶ added in v0.62.3
func (r *SessionRecordEvalRequest) WithSource(source SessionSource) *SessionRecordEvalRequest
WithSource sets the session source on the context.
type SessionRecordingOverrideEvalRequest ¶ added in v0.62.8
type SessionRecordingOverrideEvalRequest struct {
Resource WorkspaceResource
}
SessionRecordingOverrideEvalRequest is the typed authorization request for session:recording:override. The resource is the workspace whose override is read or written.
func NewSessionRecordingOverrideEvalRequest ¶ added in v0.62.8
func NewSessionRecordingOverrideEvalRequest(workspaceID string) *SessionRecordingOverrideEvalRequest
NewSessionRecordingOverrideEvalRequest returns a SessionRecordingOverrideEvalRequest for the named workspace. Chain WithOwner, then call Build.
func SessionRecordingOverrideEvalRequestFromProto ¶ added in v0.62.8
func SessionRecordingOverrideEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SessionRecordingOverrideEvalRequest, error)
SessionRecordingOverrideEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SessionRecordingOverrideEvalRequest.
func (*SessionRecordingOverrideEvalRequest) Build ¶ added in v0.62.8
func (r *SessionRecordingOverrideEvalRequest) Build() (*SessionRecordingOverrideEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*SessionRecordingOverrideEvalRequest) ToProto ¶ added in v0.62.8
func (r *SessionRecordingOverrideEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*SessionRecordingOverrideEvalRequest) Validate ¶ added in v0.62.8
func (r *SessionRecordingOverrideEvalRequest) Validate() error
Validate checks the request: owner is required; the workspace id may be empty only in a capability probe. Implements EvalRequest.
func (*SessionRecordingOverrideEvalRequest) WithOwner ¶ added in v0.62.8
func (r *SessionRecordingOverrideEvalRequest) WithOwner(owner string) *SessionRecordingOverrideEvalRequest
WithOwner sets the workspace owner's username.
type SessionRecordingReadEvalRequest ¶ added in v0.62.5
type SessionRecordingReadEvalRequest struct {
Resource WorkspaceResource
}
SessionRecordingReadEvalRequest is the validated, typed model for session:recording:read policy evaluation. It shares session:list's resource shape and validation (see the contract comment at the top of this file).
func NewSessionRecordingReadEvalRequest ¶ added in v0.62.5
func NewSessionRecordingReadEvalRequest() *SessionRecordingReadEvalRequest
NewSessionRecordingReadEvalRequest returns a SessionRecordingReadEvalRequest ready to be built. Chain WithWorkspace and/or WithOwner to narrow the scope, then call Build.
func SessionRecordingReadEvalRequestFromProto ¶ added in v0.62.5
func SessionRecordingReadEvalRequestFromProto(req *authzv1.EvaluateRequest) (*SessionRecordingReadEvalRequest, error)
SessionRecordingReadEvalRequestFromProto converts a gRPC EvaluateRequest into a validated SessionRecordingReadEvalRequest.
func (*SessionRecordingReadEvalRequest) Build ¶ added in v0.62.5
func (r *SessionRecordingReadEvalRequest) Build() (*SessionRecordingReadEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*SessionRecordingReadEvalRequest) ToProto ¶ added in v0.62.5
func (r *SessionRecordingReadEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*SessionRecordingReadEvalRequest) Validate ¶ added in v0.62.5
func (r *SessionRecordingReadEvalRequest) Validate() error
Validate checks the request: if a workspace id is set, owner must also be set. Implements EvalRequest.
func (*SessionRecordingReadEvalRequest) WithOwner ¶ added in v0.62.5
func (r *SessionRecordingReadEvalRequest) WithOwner(owner string) *SessionRecordingReadEvalRequest
WithOwner sets the owner username.
func (*SessionRecordingReadEvalRequest) WithWorkspace ¶ added in v0.62.5
func (r *SessionRecordingReadEvalRequest) WithWorkspace(workspaceID string) *SessionRecordingReadEvalRequest
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 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:create.
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 ThreatAction ¶ added in v0.63.2
type ThreatAction string
ThreatAction is the typed representation of a threat policy action.
const ( // ThreatActionDetect is the action evaluated when a workspace is // provisioned, solely to learn which attack categories worktrace watches // on it. The policy result carries a "detect" obligation; Allowed is not a // gate (see the contract above). ThreatActionDetect ThreatAction = "threat:detect" // ThreatActionDetectionOverride is the action evaluated when reading, // setting or clearing a workspace's detection override, which replaces // the threat:detect obligation for that workspace. The resource is always // one workspace (id and owner set), except in a capability probe, which // sets the owner only. ThreatActionDetectionOverride ThreatAction = "threat:detection:override" // ThreatActionList is the action evaluated when querying the threats // worktrace detected (query schema and query). ThreatActionList ThreatAction = "threat:list" )
type ThreatDetectContext ¶ added in v0.63.2
type ThreatDetectContext struct {
// Resources are the rendered chart documents keyed "Kind/name"
// (optional). They are carried JSON-encoded in context["resources"].
Resources map[string]map[string]any
Mode WorkspaceProvisionMode
Namespace string
WorkloadName string
WorkloadKind string
}
ThreatDetectContext holds the ambient attributes supplied by the caller in the context map of a threat:detect EvaluateRequest.
type ThreatDetectEvalRequest ¶ added in v0.63.2
type ThreatDetectEvalRequest struct {
Resource WorkspaceResource
Context ThreatDetectContext
}
ThreatDetectEvalRequest is the validated, typed model for threat:detect policy evaluation. Use NewThreatDetectEvalRequest to start building, then chain With* methods and call Build to get a validated instance. Use ThreatDetectEvalRequestFromProto to convert from a gRPC EvaluateRequest.
func NewThreatDetectEvalRequest ¶ added in v0.63.2
func NewThreatDetectEvalRequest(workspaceID string) *ThreatDetectEvalRequest
NewThreatDetectEvalRequest begins building a ThreatDetectEvalRequest for the named workspace. Chain With* methods, then call Build.
func ThreatDetectEvalRequestFromProto ¶ added in v0.63.2
func ThreatDetectEvalRequestFromProto(req *authzv1.EvaluateRequest) (*ThreatDetectEvalRequest, error)
ThreatDetectEvalRequestFromProto converts a gRPC EvaluateRequest into a validated ThreatDetectEvalRequest.
func (*ThreatDetectEvalRequest) Build ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) Build() (*ThreatDetectEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*ThreatDetectEvalRequest) ToProto ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Only non-empty optional fields are included. Implements EvalRequest.
func (*ThreatDetectEvalRequest) Validate ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) Validate() error
Validate checks the request against the threat:detect contract. Implements EvalRequest.
func (*ThreatDetectEvalRequest) WithBlueprintName ¶ added in v0.63.4
func (r *ThreatDetectEvalRequest) WithBlueprintName(name string) *ThreatDetectEvalRequest
WithBlueprintName sets the blueprint name on the resource attributes.
func (*ThreatDetectEvalRequest) WithMode ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) WithMode(mode WorkspaceProvisionMode, namespace string) *ThreatDetectEvalRequest
WithMode sets the provisioning mode and the namespace the workspace pod runs in.
func (*ThreatDetectEvalRequest) WithOwner ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) WithOwner(owner string) *ThreatDetectEvalRequest
WithOwner sets the workspace owner on the resource.
func (*ThreatDetectEvalRequest) WithResources ¶ added in v0.63.5
func (r *ThreatDetectEvalRequest) WithResources(resources map[string]map[string]any) *ThreatDetectEvalRequest
WithResources sets the rendered chart documents keyed "Kind/name" in the context; it is optional. Callers must leave Secrets out and strip ConfigMap data.
func (*ThreatDetectEvalRequest) WithWorkload ¶ added in v0.63.2
func (r *ThreatDetectEvalRequest) WithWorkload(name, kind string) *ThreatDetectEvalRequest
WithWorkload sets the target workload; required when mode is WorkspaceProvisionModeInject.
type ThreatDetectionOverrideEvalRequest ¶ added in v0.63.2
type ThreatDetectionOverrideEvalRequest struct {
Resource WorkspaceResource
}
ThreatDetectionOverrideEvalRequest is the typed authorization request for threat:detection:override. The resource is the workspace whose override is read or written.
func NewThreatDetectionOverrideEvalRequest ¶ added in v0.63.2
func NewThreatDetectionOverrideEvalRequest(workspaceID string) *ThreatDetectionOverrideEvalRequest
NewThreatDetectionOverrideEvalRequest returns a ThreatDetectionOverrideEvalRequest for the named workspace. Chain WithOwner, then call Build.
func ThreatDetectionOverrideEvalRequestFromProto ¶ added in v0.63.2
func ThreatDetectionOverrideEvalRequestFromProto(req *authzv1.EvaluateRequest) (*ThreatDetectionOverrideEvalRequest, error)
ThreatDetectionOverrideEvalRequestFromProto converts a gRPC EvaluateRequest into a validated ThreatDetectionOverrideEvalRequest.
func (*ThreatDetectionOverrideEvalRequest) Build ¶ added in v0.63.2
func (r *ThreatDetectionOverrideEvalRequest) Build() (*ThreatDetectionOverrideEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*ThreatDetectionOverrideEvalRequest) ToProto ¶ added in v0.63.2
func (r *ThreatDetectionOverrideEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*ThreatDetectionOverrideEvalRequest) Validate ¶ added in v0.63.2
func (r *ThreatDetectionOverrideEvalRequest) Validate() error
Validate checks the request: owner is required; the workspace id may be empty only in a capability probe. Implements EvalRequest.
func (*ThreatDetectionOverrideEvalRequest) WithOwner ¶ added in v0.63.2
func (r *ThreatDetectionOverrideEvalRequest) WithOwner(owner string) *ThreatDetectionOverrideEvalRequest
WithOwner sets the workspace owner's username.
type ThreatListEvalRequest ¶ added in v0.63.6
type ThreatListEvalRequest struct{}
ThreatListEvalRequest is the validated, typed model for threat:list policy evaluation. No resource id is required; the subject claims determine access.
func NewThreatListEvalRequest ¶ added in v0.63.6
func NewThreatListEvalRequest() *ThreatListEvalRequest
NewThreatListEvalRequest returns a ThreatListEvalRequest ready to be built.
func ThreatListEvalRequestFromProto ¶ added in v0.63.6
func ThreatListEvalRequestFromProto(req *authzv1.EvaluateRequest) (*ThreatListEvalRequest, error)
ThreatListEvalRequestFromProto converts a gRPC EvaluateRequest into a validated ThreatListEvalRequest.
func (*ThreatListEvalRequest) Build ¶ added in v0.63.6
func (r *ThreatListEvalRequest) Build() (*ThreatListEvalRequest, error)
Build returns the request. It is the required terminator for the builder chain.
func (*ThreatListEvalRequest) ToProto ¶ added in v0.63.6
func (r *ThreatListEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*ThreatListEvalRequest) Validate ¶ added in v0.63.6
func (r *ThreatListEvalRequest) Validate() error
Validate is a no-op for threat:list; no fields are required. Implements EvalRequest.
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 {
// Surface is the login surface being authenticated (context["surface"]).
Surface AuthSurface
}
UserAuthContext holds the context-scoped attributes for a user:auth policy check.
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, and surface must be a recognized value. Implements EvalRequest.
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.
func (*UserAuthEvalRequest) WithSurface ¶ added in v0.32.1
func (r *UserAuthEvalRequest) WithSurface(surface AuthSurface) *UserAuthEvalRequest
WithSurface sets the login surface being authenticated on the context.
type UserAuthMethod ¶
type UserAuthMethod string
UserAuthMethod is the typed representation of a user authentication method.
const ( // UserAuthMethodPublicKey is SSH public-key authentication; only // meaningful for AuthSurfaceSSH. UserAuthMethodPublicKey UserAuthMethod = "publickey" // UserAuthMethodPassword is username/password authentication; valid on // either surface. UserAuthMethodPassword UserAuthMethod = "password" // UserAuthMethodSSO is web SSO / OAuth login via an identity-provider // redirect; only meaningful for AuthSurfaceWeb. UserAuthMethodSSO UserAuthMethod = "sso" )
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 UserCreateEvalRequest ¶ added in v0.32.0
type UserCreateEvalRequest struct {
Resource UserResource
}
UserCreateEvalRequest is the validated, typed model for user:create policy evaluation. Use NewUserCreateEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
user:create authorizes an admin to create a brand-new local user record with no backing identity provider. The acting principal is the admin performing the creation, not the new user, so callers evaluate this with the admin's own token rather than one issued for the user being created.
func NewUserCreateEvalRequest ¶ added in v0.32.0
func NewUserCreateEvalRequest(username string) *UserCreateEvalRequest
NewUserCreateEvalRequest begins building a UserCreateEvalRequest for the given username. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func UserCreateEvalRequestFromProto ¶ added in v0.32.0
func UserCreateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserCreateEvalRequest, error)
UserCreateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserCreateEvalRequest. Returns an error if the request does not conform to the user:create contract.
func (*UserCreateEvalRequest) Build ¶ added in v0.32.0
func (r *UserCreateEvalRequest) Build() (*UserCreateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserCreateEvalRequest) ToProto ¶ added in v0.32.0
func (r *UserCreateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserCreateEvalRequest) Validate ¶ added in v0.32.0
func (r *UserCreateEvalRequest) Validate() error
Validate checks the request against the user:create contract. Implements EvalRequest.
func (*UserCreateEvalRequest) WithOrg ¶ added in v0.32.0
func (r *UserCreateEvalRequest) WithOrg(org string) *UserCreateEvalRequest
WithOrg sets the organization the new user will belong to.
type UserCredentialContext ¶ added in v0.38.0
type UserCredentialContext struct {
// CredentialType is the external service the credential authenticates to
// (context["credential_type"]). Required when DataType is
// UserDataTypeCredentials, ignored otherwise.
CredentialType UserCredentialType
}
UserCredentialContext holds the credential_type context qualifier shared by user:read and user:write when their data_type is UserDataTypeCredentials.
type UserCredentialType ¶ added in v0.38.0
type UserCredentialType string
UserCredentialType identifies which external service a stored user credential authenticates to. It is required in context whenever user:read/user:write's data_type is UserDataTypeCredentials, so policy can grant access to one credential type (e.g. "dev may write git credentials") without implicitly granting it to the other two.
const ( UserCredentialTypeKubernetes UserCredentialType = "kubernetes" UserCredentialTypeGit UserCredentialType = "git" UserCredentialTypeRegistry UserCredentialType = "registry" )
type UserDataType ¶
type UserDataType string
UserDataType identifies which slice of user data is being accessed in user:read and user:write. UserDataTypeSudo, UserDataTypeLocked, UserDataTypeOrg, UserDataTypePosix, and UserDataTypePassword are write-only values: user:read never selects them individually, since UserDataTypeProfile already returns the full profile view including sudo, locked, org, and uid/gid, and a password is never readable at all. UserDataTypeRepos is read-only in the other direction: it addresses the user's identity-provider repository catalog (owners and repos), which is never written through user:write.
const ( UserDataTypeProfile UserDataType = "profile" UserDataTypeCredentials UserDataType = "credentials" UserDataTypeBlueprints UserDataType = "blueprints" UserDataTypeRoles UserDataType = "roles" UserDataTypeKeys UserDataType = "keys" UserDataTypeRepos UserDataType = "repos" UserDataTypeSudo UserDataType = "sudo" UserDataTypeLocked UserDataType = "locked" UserDataTypeOrg UserDataType = "org" UserDataTypePosix UserDataType = "posix" UserDataTypePassword UserDataType = "password" UserDataTypeEnvVars UserDataType = "envvars" UserDataTypeLogins UserDataType = "logins" )
type UserDeleteEvalRequest ¶ added in v0.32.0
type UserDeleteEvalRequest struct {
Resource UserResource
}
UserDeleteEvalRequest is the validated, typed model for user:delete policy evaluation. Use NewUserDeleteEvalRequest to start building, then chain With* methods and call Build to get a validated instance.
Like user:create, the acting principal is the admin performing the deletion, not the user being deleted, so callers evaluate this with the admin's own token.
func NewUserDeleteEvalRequest ¶ added in v0.32.0
func NewUserDeleteEvalRequest(username string) *UserDeleteEvalRequest
NewUserDeleteEvalRequest begins building a UserDeleteEvalRequest for the given username. Chain With* methods to supply additional fields, then call Build to validate and obtain the final struct.
func UserDeleteEvalRequestFromProto ¶ added in v0.32.0
func UserDeleteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserDeleteEvalRequest, error)
UserDeleteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserDeleteEvalRequest. Returns an error if the request does not conform to the user:delete contract.
func (*UserDeleteEvalRequest) Build ¶ added in v0.32.0
func (r *UserDeleteEvalRequest) Build() (*UserDeleteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserDeleteEvalRequest) ToProto ¶ added in v0.32.0
func (r *UserDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserDeleteEvalRequest) Validate ¶ added in v0.32.0
func (r *UserDeleteEvalRequest) Validate() error
Validate checks the request against the user:delete contract. Implements EvalRequest.
func (*UserDeleteEvalRequest) WithOrg ¶ added in v0.32.0
func (r *UserDeleteEvalRequest) WithOrg(org string) *UserDeleteEvalRequest
WithOrg sets the user's organization on the resource.
type UserExistsEvalRequest ¶ added in v0.36.0
type UserExistsEvalRequest struct {
Field UserExistsField
}
UserExistsEvalRequest is the validated, typed model for user:exists policy evaluation. No resource id is required — the check targets an arbitrary, possibly nonexistent, username or email supplied by the caller, not a record the subject already has standing to act on.
func NewUserExistsEvalRequest ¶ added in v0.36.0
func NewUserExistsEvalRequest(field UserExistsField) *UserExistsEvalRequest
NewUserExistsEvalRequest begins building a UserExistsEvalRequest for the given field. Call Build to validate and obtain the final struct.
func UserExistsEvalRequestFromProto ¶ added in v0.36.0
func UserExistsEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserExistsEvalRequest, error)
UserExistsEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserExistsEvalRequest.
func (*UserExistsEvalRequest) Build ¶ added in v0.36.0
func (r *UserExistsEvalRequest) Build() (*UserExistsEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserExistsEvalRequest) ToProto ¶ added in v0.36.0
func (r *UserExistsEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserExistsEvalRequest) Validate ¶ added in v0.36.0
func (r *UserExistsEvalRequest) Validate() error
Validate checks the request against the user:exists contract. Implements EvalRequest.
type UserExistsField ¶ added in v0.36.0
type UserExistsField string
UserExistsField identifies which identifier user:exists is checking.
const ( UserExistsFieldUsername UserExistsField = "username" UserExistsFieldEmail UserExistsField = "email" )
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 UserReadEvalRequest ¶
type UserReadEvalRequest struct {
Resource UserResource
DataType UserDataType
Context UserCredentialContext
}
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) WithCredentialType ¶ added in v0.38.0
func (r *UserReadEvalRequest) WithCredentialType(t UserCredentialType) *UserReadEvalRequest
WithCredentialType sets the credential type being accessed; required when DataType is UserDataTypeCredentials.
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 UserTokenDeleteEvalRequest ¶ added in v0.34.0
type UserTokenDeleteEvalRequest struct {
Resource UserResource
}
UserTokenDeleteEvalRequest is the validated, typed model for token:delete policy evaluation. The resource ID is the username who owns the token being permanently deleted.
func NewUserTokenDeleteEvalRequest ¶ added in v0.34.0
func NewUserTokenDeleteEvalRequest(username string) *UserTokenDeleteEvalRequest
NewUserTokenDeleteEvalRequest begins building a UserTokenDeleteEvalRequest for the given username (the token owner). Call Build to validate.
func UserTokenDeleteEvalRequestFromProto ¶ added in v0.34.0
func UserTokenDeleteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserTokenDeleteEvalRequest, error)
UserTokenDeleteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserTokenDeleteEvalRequest.
func (*UserTokenDeleteEvalRequest) Build ¶ added in v0.34.0
func (r *UserTokenDeleteEvalRequest) Build() (*UserTokenDeleteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserTokenDeleteEvalRequest) ToProto ¶ added in v0.34.0
func (r *UserTokenDeleteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserTokenDeleteEvalRequest) Validate ¶ added in v0.34.0
func (r *UserTokenDeleteEvalRequest) Validate() error
Validate checks the request against the token:delete contract. Implements EvalRequest.
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 UserTokenWriteEvalRequest ¶ added in v0.34.0
type UserTokenWriteEvalRequest struct {
Resource UserResource
}
UserTokenWriteEvalRequest is the validated, typed model for token:write policy evaluation. The resource ID is the username who owns the token being updated (active flag and/or scopes).
func NewUserTokenWriteEvalRequest ¶ added in v0.34.0
func NewUserTokenWriteEvalRequest(username string) *UserTokenWriteEvalRequest
NewUserTokenWriteEvalRequest begins building a UserTokenWriteEvalRequest for the given username (the token owner). Call Build to validate.
func UserTokenWriteEvalRequestFromProto ¶ added in v0.34.0
func UserTokenWriteEvalRequestFromProto(req *authzv1.EvaluateRequest) (*UserTokenWriteEvalRequest, error)
UserTokenWriteEvalRequestFromProto converts a gRPC EvaluateRequest into a validated UserTokenWriteEvalRequest.
func (*UserTokenWriteEvalRequest) Build ¶ added in v0.34.0
func (r *UserTokenWriteEvalRequest) Build() (*UserTokenWriteEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied. It is the required terminator for the builder chain.
func (*UserTokenWriteEvalRequest) ToProto ¶ added in v0.34.0
func (r *UserTokenWriteEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest, attaching the supplied JWT token. Implements EvalRequest.
func (*UserTokenWriteEvalRequest) Validate ¶ added in v0.34.0
func (r *UserTokenWriteEvalRequest) Validate() error
Validate checks the request against the token:write contract. Implements EvalRequest.
type UserWriteEvalRequest ¶ added in v0.29.11
type UserWriteEvalRequest struct {
Resource UserResource
DataType UserDataType
Context UserCredentialContext
}
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) WithCredentialType ¶ added in v0.38.0
func (r *UserWriteEvalRequest) WithCredentialType(t UserCredentialType) *UserWriteEvalRequest
WithCredentialType sets the credential type being mutated; required when DataType is UserDataTypeCredentials.
func (*UserWriteEvalRequest) WithDataType ¶ added in v0.29.13
func (r *UserWriteEvalRequest) WithDataType(dt UserDataType) *UserWriteEvalRequest
WithDataType sets the data type being mutated.
type UsernameObligation ¶ added in v0.30.11
type UsernameObligation struct {
// Username is the single user the enforcer should restrict the listing to.
Username string
}
UsernameObligation is the typed representation of the "username" obligation key returned by the policy engine in a PolicyResult for session:list.
func ParseUsernameObligation ¶ added in v0.30.11
func ParseUsernameObligation(obligations map[string]string) (UsernameObligation, bool)
ParseUsernameObligation reads the "username" key from the obligations map. Returns (obligation, true) when the key is present, (zero value, false) when the policy did not set a username obligation — in that case the enforcer should not scope the listing to a single user.
type WorkspaceAccessEvalRequest ¶
type WorkspaceAccessEvalRequest struct {
Action WorkspaceAction
Resource WorkspaceResource
}
WorkspaceAccessEvalRequest is the validated, typed model for workspace:read workspace:delete and workspace:start:force. 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 / workspace:start:force 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" WorkspaceActionUpdate WorkspaceAction = "workspace:update" WorkspaceActionDelete WorkspaceAction = "workspace:delete" // WorkspaceActionStartForce is evaluated alongside the right to start a // workspace, to decide whether the start may be forced: started although // its schedule does not allow it (after its expiry has passed). It never // gates the start itself. WorkspaceActionStartForce WorkspaceAction = "workspace:start:force" 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
}
WorkspaceConnectContext holds the session type 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) 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" )
type WorkspaceDataType ¶ added in v0.49.0
type WorkspaceDataType string
WorkspaceDataType identifies which mutable slice of a workspace's runtime configuration is being changed in workspace:update. Each value is folded into the PAT scope string as a fourth segment ("workspace:update:<data_type>", see scope.go), so a role or token can be scoped to e.g. resize CPU without also being able to rewrite egress rules.
const ( // WorkspaceDataTypeCPU covers a change to the workspace's CPU limit. WorkspaceDataTypeCPU WorkspaceDataType = "cpu" // WorkspaceDataTypeMemory covers a change to the workspace's memory limit. WorkspaceDataTypeMemory WorkspaceDataType = "memory" // WorkspaceDataTypeNetwork covers a change to the workspace's network // policy class and/or egress rules. WorkspaceDataTypeNetwork WorkspaceDataType = "network" // WorkspaceDataTypeSchedule covers an override of the workspace's run // schedule (expiry and grace periods), or its revert to the blueprint's. WorkspaceDataTypeSchedule WorkspaceDataType = "schedule" )
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) WithSource ¶ added in v0.61.3
func (r *WorkspaceEvalRequest) WithSource(source WorkspaceProvisionSource) *WorkspaceEvalRequest
WithSource sets where the blueprint originates (catalog or git); required for WorkspaceActionProvision. Use WorkspaceSourceFromBlueprintKind to derive it from the resolved userstr identity rather than setting it by hand.
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 WorkspaceOwnerContext ¶ added in v0.38.0
type WorkspaceOwnerContext struct {
// Mode is which kind of workspace is being created: standalone or
// inject. Required for workspace:create.
Mode WorkspaceProvisionMode
// Source is where the blueprint will come from: catalog or git. Required
// for workspace:create. Unlike workspace:provision's Source, this is
// derived from the parsed userstr before any blueprint is fetched — see
// WorkspaceSourceFromBlueprintKind.
Source WorkspaceProvisionSource
}
WorkspaceOwnerContext holds the context fields for workspace:create. Unused for workspace:list.
type WorkspaceOwnerEvalRequest ¶
type WorkspaceOwnerEvalRequest struct {
Action WorkspaceAction
Resource WorkspaceResource
Context WorkspaceOwnerContext
}
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.
func (*WorkspaceOwnerEvalRequest) WithMode ¶ added in v0.38.0
func (r *WorkspaceOwnerEvalRequest) WithMode(mode WorkspaceProvisionMode) *WorkspaceOwnerEvalRequest
WithMode sets the provisioning mode; required for workspace:create.
func (*WorkspaceOwnerEvalRequest) WithSource ¶ added in v0.61.3
func (r *WorkspaceOwnerEvalRequest) WithSource(source WorkspaceProvisionSource) *WorkspaceOwnerEvalRequest
WithSource sets where the blueprint will come from (catalog or git); required for workspace:create. Use WorkspaceSourceFromBlueprintKind to derive it from the parsed userstr rather than setting it by hand.
type WorkspaceProvisionContext ¶
type WorkspaceProvisionContext struct {
Blueprint *models.Blueprint
Mode WorkspaceProvisionMode
Source WorkspaceProvisionSource
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 WorkspaceProvisionSource ¶ added in v0.61.3
type WorkspaceProvisionSource string
WorkspaceProvisionSource identifies where the blueprint used to create or provision a workspace comes from. It is orthogonal to WorkspaceProvisionMode (standalone/inject): source says where the blueprint originates, mode says how the workspace attaches to its runtime.
const ( // WorkspaceSourceCatalog means the blueprint was resolved by name from the // org/global blueprint catalog (userstr.BlueprintKindImplicit or // BlueprintKindExplicit). WorkspaceSourceCatalog WorkspaceProvisionSource = "catalog" // WorkspaceSourceGit means the blueprint was supplied ad hoc by a git // repository's k8shell file (userstr.BlueprintKindCustom). A git-sourced // blueprint still names a Template that must appear in the caller's // blueprint allowlist, but it can override arbitrary fields (resources, // storages, init scripts, apps, ...) inherited from that template. WorkspaceSourceGit WorkspaceProvisionSource = "git" )
func WorkspaceSourceFromBlueprintKind ¶ added in v0.61.3
func WorkspaceSourceFromBlueprintKind(k userstr.BlueprintKind) WorkspaceProvisionSource
WorkspaceSourceFromBlueprintKind maps a userstr.BlueprintKind — as parsed from a userstr, or resolved from the identity the provisioner builds off one — to the coarser WorkspaceProvisionSource the workspace:create and workspace:provision contracts use. Implicit and Explicit both name a blueprint from the catalog; only Custom means the blueprint came from a git repository's k8shell file. Callers (api-server, ssh-proxy, the provisioner) use this instead of re-deriving the mapping themselves, so all three stay in lockstep as new BlueprintKind values are added.
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.
type WorkspaceUpdateEvalRequest ¶ added in v0.49.0
type WorkspaceUpdateEvalRequest struct {
Resource WorkspaceResource
DataType WorkspaceDataType
}
WorkspaceUpdateEvalRequest is the validated, typed model for workspace:update. The resource id is the workspace name; the owner attribute identifies who owns it; the data_type context says which slice of the workspace's runtime configuration (cpu | memory | network | schedule) is being changed.
func NewWorkspaceUpdateEvalRequest ¶ added in v0.49.0
func NewWorkspaceUpdateEvalRequest(workspaceName string) *WorkspaceUpdateEvalRequest
NewWorkspaceUpdateEvalRequest begins building a WorkspaceUpdateEvalRequest for the given workspace name.
func WorkspaceUpdateEvalRequestFromProto ¶ added in v0.49.0
func WorkspaceUpdateEvalRequestFromProto(req *authzv1.EvaluateRequest) (*WorkspaceUpdateEvalRequest, error)
WorkspaceUpdateEvalRequestFromProto converts a gRPC EvaluateRequest into a validated WorkspaceUpdateEvalRequest.
func (*WorkspaceUpdateEvalRequest) Build ¶ added in v0.49.0
func (r *WorkspaceUpdateEvalRequest) Build() (*WorkspaceUpdateEvalRequest, error)
Build validates the request and returns it if all constraints are satisfied.
func (*WorkspaceUpdateEvalRequest) ToProto ¶ added in v0.49.0
func (r *WorkspaceUpdateEvalRequest) ToProto(token string) *authzv1.EvaluateRequest
ToProto serializes the typed request into a gRPC EvaluateRequest. Implements EvalRequest.
func (*WorkspaceUpdateEvalRequest) Validate ¶ added in v0.49.0
func (r *WorkspaceUpdateEvalRequest) Validate() error
Validate checks the request against the workspace:update contract. Implements EvalRequest.
func (*WorkspaceUpdateEvalRequest) WithDataType ¶ added in v0.49.0
func (r *WorkspaceUpdateEvalRequest) WithDataType(dt WorkspaceDataType) *WorkspaceUpdateEvalRequest
WithDataType sets which slice of the workspace configuration is changing.
func (*WorkspaceUpdateEvalRequest) WithOwner ¶ added in v0.49.0
func (r *WorkspaceUpdateEvalRequest) WithOwner(owner string) *WorkspaceUpdateEvalRequest
WithOwner sets the owner username on the resource.