Documentation
¶
Overview ¶
Package v1 defines schemes used by apimachinery-apiserver.
Index ¶
Constants ¶
const GroupName = "iam.api"
GroupName is the group name use in this package. If use a public domain name, need set the GroupName to service name. For example: if restful path is: https://marmotedu.com/apimachinery/v1/secrets, we can set GroupName="apimachinery".
Variables ¶
var SchemeGroupVersion = scheme.GroupVersion{Group: GroupName, Version: "v1"}
SchemeGroupVersion is group version used to register these objects.
Functions ¶
func Resource ¶
func Resource(resource string) scheme.GroupResource
Resource takes an unqualified resource and returns a Group qualified GroupResource.
Types ¶
type AuthzPolicy ¶
type AuthzPolicy struct {
ladon.DefaultPolicy
}
AuthzPolicy defines iam policy type.
func (AuthzPolicy) String ¶
func (ap AuthzPolicy) String() string
String returns the string format of Policy.
type Policy ¶
type Policy struct {
// Standard object's metadata.
metav1.ObjectMeta `json:"metadata,omitempty"`
// The user of the policy.
Username string `json:"username" gorm:"column:username" validate:"omitempty"`
// AuthzPolicy policy, will not be stored in db.
Policy AuthzPolicy `json:"policy,omitempty" gorm:"-" validate:"omitempty"`
// The ladon policy content, just a string format of ladon.DefaultPolicy. DO NOT modify directly.
PolicyShadow string `json:"-" gorm:"column:policyShadow" validate:"omitempty"`
}
Policy represents a policy restful resource, include a ladon policy. It is also used as gorm model.
func (*Policy) AfterCreate ¶
AfterCreate run after create database record.
func (*Policy) AfterFind ¶
AfterFind run after find to unmarshal a policy string into ladon.DefaultPolicy struct.
func (*Policy) BeforeCreate ¶
BeforeCreate run before create database record.
func (*Policy) BeforeUpdate ¶
BeforeUpdate run before update database record.
type PolicyList ¶
type PolicyList struct {
// Standard list metadata.
metav1.ListMeta `json:",inline"`
// List of policies.
Items []*Policy `json:"items"`
}
PolicyList is the whole list of all policies which have been stored in stroage.
type Secret ¶
type Secret struct {
// Standard object's metadata.
metav1.ObjectMeta ` json:"metadata,omitempty"`
Username string `json:"username" gorm:"column:username" validate:"omitempty"`
//nolint: tagliatelle
SecretID string `json:"secretID" gorm:"column:secretID" validate:"omitempty"`
SecretKey string `json:"secretKey" gorm:"column:secretKey" validate:"omitempty"`
// Required: true
Expires int64 `json:"expires" gorm:"column:expires" validate:"omitempty"`
Description string `json:"description" gorm:"column:description" validate:"description"`
}
Secret represents a secret restful resource. It is also used as gorm model.
func (*Secret) AfterCreate ¶
AfterCreate run after create database record.
type SecretList ¶
type SecretList struct {
// Standard list metadata.
metav1.ListMeta `json:",inline"`
// List of secrets
Items []*Secret `json:"items"`
}
SecretList is the whole list of all secrets which have been stored in stroage.
type User ¶
type User struct {
// Standard object's metadata.
metav1.ObjectMeta `json:"metadata,omitempty"`
Status int `json:"status" gorm:"column:status" validate:"omitempty"`
// Required: true
Nickname string `json:"nickname" gorm:"column:nickname" validate:"required,min=1,max=30"`
// Required: true
Password string `json:"password,omitempty" gorm:"column:password" validate:"required"`
// Required: true
Email string `json:"email" gorm:"column:email" validate:"required,email,min=1,max=100"`
Phone string `json:"phone" gorm:"column:phone" validate:"omitempty"`
IsAdmin int `json:"isAdmin,omitempty" gorm:"column:isAdmin" validate:"omitempty"`
TotalPolicy int64 `json:"totalPolicy" gorm:"-" validate:"omitempty"`
LoginedAt time.Time `json:"loginedAt,omitempty" gorm:"column:loginedAt"`
}
User represents a user restful resource. It is also used as gorm model.
func (*User) AfterCreate ¶
AfterCreate run after create database record.
func (*User) Compare ¶
Compare with the plain text password. Returns true if it's the same as the encrypted one (in the `User` struct).
func (*User) ValidateUpdate ¶
ValidateUpdate validates that a user object is valid when update. Like User.Validate but not validate password.