65 lines
3.8 KiB
Go
65 lines
3.8 KiB
Go
package model
|
|
|
|
// AgnetApprovalRequest records a user-visible approval gate for a
|
|
// high-risk Agnet operation. It intentionally stores only a Secret
|
|
// Store reference for credential-backed operations; plaintext secrets
|
|
// must never be written to this table.
|
|
type AgnetApprovalRequest struct {
|
|
Id int `json:"id" gorm:"primaryKey"`
|
|
ApprovalID string `json:"approval_id" gorm:"type:varchar(64);uniqueIndex;not null"`
|
|
UserId int `json:"user_id" gorm:"index;not null"`
|
|
DeploymentID string `json:"deployment_id" gorm:"type:varchar(64);index"`
|
|
BindingScope string `json:"binding_scope" gorm:"type:varchar(512);index"`
|
|
Operation string `json:"operation" gorm:"type:varchar(128);index;not null"`
|
|
ResourceID string `json:"resource_id" gorm:"type:varchar(128);index"`
|
|
ResourceType string `json:"resource_type" gorm:"type:varchar(32);index"`
|
|
ResourceScope string `json:"resource_scope" gorm:"type:varchar(512)"`
|
|
TargetRole string `json:"target_role" gorm:"type:varchar(128);index"`
|
|
RiskLevel string `json:"risk_level" gorm:"type:varchar(32);index;not null"`
|
|
RequiresCredential bool `json:"requires_credential" gorm:"default:false"`
|
|
SecretRef string `json:"secret_ref" gorm:"type:varchar(512)"`
|
|
CredentialLeaseID string `json:"credential_lease_id" gorm:"type:varchar(64);index"`
|
|
Status string `json:"status" gorm:"type:varchar(32);index;not null"`
|
|
RequestedBy string `json:"requested_by" gorm:"type:varchar(64)"`
|
|
DecidedBy string `json:"decided_by" gorm:"type:varchar(64)"`
|
|
RequestReason string `json:"request_reason" gorm:"type:text"`
|
|
DecisionReason string `json:"decision_reason" gorm:"type:text"`
|
|
TTLSeconds int `json:"ttl_seconds" gorm:"default:0"`
|
|
ExpiresAt int64 `json:"expires_at" gorm:"bigint;index"`
|
|
DecidedAt int64 `json:"decided_at" gorm:"bigint;default:0"`
|
|
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime;column:created_at"`
|
|
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime;column:updated_at"`
|
|
}
|
|
|
|
func (AgnetApprovalRequest) TableName() string {
|
|
return "agnet_approval_requests"
|
|
}
|
|
|
|
// AgnetCredentialLease is the Manager-side short-lived credential
|
|
// handle produced after an approval succeeds. CredentialRef is the
|
|
// external handle; SecretRef is internal and points at Azure Key Vault.
|
|
type AgnetCredentialLease struct {
|
|
Id int `json:"id" gorm:"primaryKey"`
|
|
LeaseID string `json:"lease_id" gorm:"type:varchar(64);uniqueIndex;not null"`
|
|
CredentialRef string `json:"credential_ref" gorm:"type:varchar(128);uniqueIndex;not null"`
|
|
ApprovalID string `json:"approval_id" gorm:"type:varchar(64);index;not null"`
|
|
UserId int `json:"user_id" gorm:"index;not null"`
|
|
DeploymentID string `json:"deployment_id" gorm:"type:varchar(64);index"`
|
|
BindingScope string `json:"binding_scope" gorm:"type:varchar(512);index"`
|
|
ResourceID string `json:"resource_id" gorm:"type:varchar(128);index"`
|
|
ResourceType string `json:"resource_type" gorm:"type:varchar(32);index"`
|
|
ResourceScope string `json:"resource_scope" gorm:"type:varchar(512)"`
|
|
TargetRole string `json:"target_role" gorm:"type:varchar(128);index"`
|
|
SecretRef string `json:"secret_ref" gorm:"type:varchar(512);not null"`
|
|
Status string `json:"status" gorm:"type:varchar(32);index;not null"`
|
|
TTLSeconds int `json:"ttl_seconds" gorm:"default:0"`
|
|
ExpiresAt int64 `json:"expires_at" gorm:"bigint;index"`
|
|
RevokedAt int64 `json:"revoked_at" gorm:"bigint;default:0"`
|
|
CreatedAt int64 `json:"created_at" gorm:"autoCreateTime;column:created_at"`
|
|
UpdatedAt int64 `json:"updated_at" gorm:"autoUpdateTime;column:updated_at"`
|
|
}
|
|
|
|
func (AgnetCredentialLease) TableName() string {
|
|
return "agnet_credential_leases"
|
|
}
|