Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientPrincipal ¶
func UserPrincipal ¶
Types ¶
type Action ¶
type Attribute ¶
type Attributes ¶
type Attributes []*Attribute
func (Attributes) GetAttribute ¶
func (a Attributes) GetAttribute(key string) string
type Audit ¶
type Audit struct {
ID int64 `json:"id" gorm:"primarykey;autoIncrement"`
Date time.Time `json:"date"`
Principal string `json:"principal"`
ResourceKind string `json:"resource_kind"`
ResourceValue string `json:"resource_value"`
Action string `json:"action"`
IsAllowed bool `json:"is_allowed"`
PolicyID string `json:"policy_id"`
}
type Client ¶
type Client struct {
ID string `json:"client_id" gorm:"primarykey"`
Secret string `json:"client_secret" gorm:"type:varchar(512)"`
Name string `json:"name"`
Domain string `json:"domain" gorm:"type:varchar(512)"`
Data string `json:"data,omitempty" gorm:"type:text"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type CompiledPolicy ¶
type CompiledPolicy struct {
PolicyID string `json:"policy_id" gorm:"index"`
PrincipalID string `json:"principal_id" gorm:"index"`
ResourceKind string `json:"resource_kind" gorm:"index"`
ResourceValue string `json:"resource_value" gorm:"index"`
ActionID string `json:"action_id" gorm:"index"`
Version int64 `json:"version" gorm:"index"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (CompiledPolicy) TableName ¶
func (CompiledPolicy) TableName() string
type Models ¶
type Models interface {
Action | Audit | Attribute | Client | CompiledPolicy | Policy | Principal | Resource | Role | Stats | Token | User
}
Models is a constraint interface that allows only authz library models.
type Policy ¶
type Policy struct {
ID string `json:"id" gorm:"primarykey"`
Resources []*Resource `json:"resources,omitempty" gorm:"many2many:authz_policies_resources;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Actions []*Action `json:"actions,omitempty" gorm:"many2many:authz_policies_actions;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
AttributeRules datatypes.JSONType[[]string] `json:"attribute_rules,omitempty" swaggertype:"object"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Roles []*Role `json:"-" gorm:"many2many:authz_roles_policies"`
}
type Principal ¶
type Principal struct {
ID string `json:"id" gorm:"primarykey"`
Roles []*Role `json:"roles,omitempty" gorm:"many2many:authz_principals_roles;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Attributes Attributes `json:"attributes,omitempty" gorm:"many2many:authz_principals_attributes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
IsLocked bool `json:"is_locked" gorm:"is_locked"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Resource ¶
type Resource struct {
ID string `json:"id" gorm:"primarykey"`
Kind string `json:"kind" gorm:"kind"`
Value string `json:"value" gorm:"value"`
Attributes Attributes `json:"attributes,omitempty" gorm:"many2many:authz_resources_attributes;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
IsLocked bool `json:"is_locked" gorm:"is_locked"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type Role ¶
type Role struct {
ID string `json:"id" gorm:"primarykey"`
Policies []*Policy `json:"policies,omitempty" gorm:"many2many:authz_roles_policies;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Principals []*Principal `json:"-" gorm:"many2many:authz_principals_roles;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}
type Stats ¶
type Token ¶
type User ¶
type User struct {
Username string `json:"username" gorm:"primarykey"`
PasswordHash string `json:"-" gorm:"password_hash"`
Password string `json:"password,omitempty" gorm:"-"` // Only used to display generated password after creation
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Click to show internal directories.
Click to hide internal directories.