43 lines
2.7 KiB
Go
43 lines
2.7 KiB
Go
package model
|
|
|
|
// ResourceBinding is the Manager-side resource record described by docs/plan.md P1.
|
|
// It stores user-owned resource metadata and a Secret Store reference only;
|
|
// plaintext credentials must never be stored here.
|
|
type ResourceBinding struct {
|
|
Id int `json:"id"`
|
|
UserId int `json:"user_id" gorm:"index;not null"`
|
|
TenantId string `json:"tenant_id" gorm:"type:varchar(64);index"` // legacy compatibility only; do not use as a product boundary.
|
|
ProjectId string `json:"project_id" gorm:"type:varchar(64);index"`
|
|
BindingScope string `json:"binding_scope" gorm:"type:varchar(512);index"`
|
|
Name string `json:"name" gorm:"type:varchar(128);not null"`
|
|
ResourceType string `json:"resource_type" gorm:"type:varchar(32);index;not null"`
|
|
Provider string `json:"provider" gorm:"type:varchar(64);default:'custom'"`
|
|
ExternalId string `json:"external_id" gorm:"type:varchar(512)"`
|
|
SecretRef string `json:"secret_ref" gorm:"type:varchar(512)"`
|
|
Metadata string `json:"metadata" gorm:"type:text"`
|
|
PermissionScope string `json:"permission_scope" gorm:"type:text"`
|
|
Constraints string `json:"constraints" gorm:"type:text"`
|
|
Status string `json:"status" gorm:"type:varchar(32);default:'active';index"`
|
|
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime;column:created_at"`
|
|
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime;column:updated_at"`
|
|
}
|
|
|
|
// ResourceGrant assigns a ResourceBinding to a role and child Agnet.
|
|
// It is the auditable Manager expression of "user grants bound resource to role".
|
|
type ResourceGrant struct {
|
|
Id int `json:"id"`
|
|
UserId int `json:"user_id" gorm:"index;not null"`
|
|
TenantId string `json:"tenant_id" gorm:"type:varchar(64);index"` // legacy compatibility only; do not use as a product boundary.
|
|
ProjectId string `json:"project_id" gorm:"type:varchar(64);index"`
|
|
BindingScope string `json:"binding_scope" gorm:"type:varchar(512);index"`
|
|
ResourceId int `json:"resource_id" gorm:"index;not null"`
|
|
Role string `json:"role" gorm:"type:varchar(128);index;not null"`
|
|
AgnetId string `json:"agnet_id" gorm:"type:varchar(128);index;not null"`
|
|
PermissionScope string `json:"permission_scope" gorm:"type:text"`
|
|
Constraints string `json:"constraints" gorm:"type:text"`
|
|
Status string `json:"status" gorm:"type:varchar(32);default:'active';index"`
|
|
RevokedAt int64 `json:"revoked_at" gorm:"default:0"`
|
|
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime;column:created_at"`
|
|
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime;column:updated_at"`
|
|
}
|