feat: add API key scope to restrict access to user data (#17692)

This commit is contained in:
Thomas Kosiewski
2025-05-15 15:32:52 +01:00
committed by GitHub
parent ee2aeb44d7
commit 1bacd82e80
28 changed files with 824 additions and 447 deletions
+60
View File
@@ -74,6 +74,64 @@ func AllAPIKeyScopeValues() []APIKeyScope {
}
}
type AgentKeyScopeEnum string
const (
AgentKeyScopeEnumAll AgentKeyScopeEnum = "all"
AgentKeyScopeEnumNoUserData AgentKeyScopeEnum = "no_user_data"
)
func (e *AgentKeyScopeEnum) Scan(src interface{}) error {
switch s := src.(type) {
case []byte:
*e = AgentKeyScopeEnum(s)
case string:
*e = AgentKeyScopeEnum(s)
default:
return fmt.Errorf("unsupported scan type for AgentKeyScopeEnum: %T", src)
}
return nil
}
type NullAgentKeyScopeEnum struct {
AgentKeyScopeEnum AgentKeyScopeEnum `json:"agent_key_scope_enum"`
Valid bool `json:"valid"` // Valid is true if AgentKeyScopeEnum is not NULL
}
// Scan implements the Scanner interface.
func (ns *NullAgentKeyScopeEnum) Scan(value interface{}) error {
if value == nil {
ns.AgentKeyScopeEnum, ns.Valid = "", false
return nil
}
ns.Valid = true
return ns.AgentKeyScopeEnum.Scan(value)
}
// Value implements the driver Valuer interface.
func (ns NullAgentKeyScopeEnum) Value() (driver.Value, error) {
if !ns.Valid {
return nil, nil
}
return string(ns.AgentKeyScopeEnum), nil
}
func (e AgentKeyScopeEnum) Valid() bool {
switch e {
case AgentKeyScopeEnumAll,
AgentKeyScopeEnumNoUserData:
return true
}
return false
}
func AllAgentKeyScopeEnumValues() []AgentKeyScopeEnum {
return []AgentKeyScopeEnum{
AgentKeyScopeEnumAll,
AgentKeyScopeEnumNoUserData,
}
}
type AppSharingLevel string
const (
@@ -3406,6 +3464,8 @@ type WorkspaceAgent struct {
// Specifies the order in which to display agents in user interfaces.
DisplayOrder int32 `db:"display_order" json:"display_order"`
ParentID uuid.NullUUID `db:"parent_id" json:"parent_id"`
// Defines the scope of the API key associated with the agent. 'all' allows access to everything, 'no_user_data' restricts it to exclude user data.
APIKeyScope AgentKeyScopeEnum `db:"api_key_scope" json:"api_key_scope"`
}
// Workspace agent devcontainer configuration