Documentation ¶
Overview ¶
The keys module containing the keys CRUD operation and relationship CRUD
models.go: definition of orm based data model
routers.go: router binding and core logic
serializers.go: definition the schema of return data
validators.go: definition the validator of form data
Index ¶
- Constants
- func AuthMiddleware() gin.HandlerFunc
- func DeleteTokenModel(condition interface{}) error
- func GetRemainingTTL(token TokenModel) (int, error)
- func NewAccessor() (string, error)
- func NewToken(tokenType string) (string, error)
- func SaveOne(data interface{}) error
- func SeedDB(c *common.Config) error
- func TokenCreate(c *gin.Context)
- func TokenDelete(c *gin.Context)
- func TokenRegister(router *gin.RouterGroup)
- func TokenRenew(c *gin.Context)
- func TokenRetrieve(c *gin.Context)
- func TokenSelfRenew(c *gin.Context)
- func TokenSelfRetrieve(c *gin.Context)
- type TokenLookupModelValidator
- type TokenModel
- type TokenModelValidator
- type TokenResponse
- type TokenSerializer
Constants ¶
View Source
const ( TOKEN_TYPE_SERVICE = "service" TOKEN_TYPE_BATCH = "batch" TOKEN_ACCESSOR = "accessor" )
View Source
const ( // Len in bytes TOKEN_TYPE_SERVICE_LEN = 70 TOKEN_TYPE_BATCH_LEN = 92 TOKEN_ACCESSOR_LEN = 20 )
Variables ¶
This section is empty.
Functions ¶
func AuthMiddleware ¶
func AuthMiddleware() gin.HandlerFunc
func DeleteTokenModel ¶
func DeleteTokenModel(condition interface{}) error
func GetRemainingTTL ¶
func GetRemainingTTL(token TokenModel) (int, error)
func NewAccessor ¶
func TokenCreate ¶
func TokenDelete ¶
func TokenRegister ¶
func TokenRegister(router *gin.RouterGroup)
func TokenRenew ¶
func TokenRetrieve ¶
func TokenSelfRenew ¶
func TokenSelfRetrieve ¶
Types ¶
type TokenLookupModelValidator ¶
type TokenLookupModelValidator struct { TokenID string `form:"token" json:"token"` Accessor string `form:"accessor" json:"accessor"` // contains filtered or unexported fields }
func NewTokenLookupModelValidator ¶
func NewTokenLookupModelValidator(self bool) TokenLookupModelValidator
func NewTokenLookupModelValidatorFillWith ¶
func NewTokenLookupModelValidatorFillWith(tokenModel TokenModel) TokenLookupModelValidator
type TokenModel ¶
type TokenModel struct { gorm.Model TokenID string `gorm:"unique_index"` Accessor string `gorm:"unique_index"` CreationTime time.Time CreationTTL int DisplayName string EntityID string ExpireTime time.Time ExplicitMaxTTL int LastRenewalTime time.Time ExternalNamespacePolicies string IdentityPolicies []policies.PolicyModel `gorm:"many2many:token_policy_ip"` Meta *string NumUses int Orphan bool Path string Policies []policies.PolicyModel `gorm:"many2many:token_policy"` Renewable bool TTL int Period int Type string }
func FindOneToken ¶
func FindOneToken(condition interface{}) (TokenModel, error)
func NewRootToken ¶
func NewRootToken() *TokenModel
func (*TokenModel) Renew ¶
func (s *TokenModel) Renew() error
func (*TokenModel) Update ¶
func (p *TokenModel) Update(data interface{}) error
type TokenModelValidator ¶
type TokenModelValidator struct { Policies []string `json:"policies"` TTL string `json:"ttl"` ExplicitMaxTTL string `json:"explicit_max_ttl"` Period string `json:"period"` DisplayName string `json:"display_name"` NumUses int `json:"num_uses"` Renewable bool `json:"renewable"` Type string `json:"type"` EntityAlias string `json:"entity_alias"` // contains filtered or unexported fields }
func NewTokenModelValidator ¶
func NewTokenModelValidator() TokenModelValidator
func NewTokenModelValidatorFillWith ¶
func NewTokenModelValidatorFillWith(tokenModel TokenModel) TokenModelValidator
type TokenResponse ¶
type TokenResponse struct { TokenID string `json:"id,omitempty"` Accessor string `json:"accessor"` CreationTime int `json:"creation_time"` CreationTTL int `json:"creation_ttl"` DisplayName string `json:"display_name"` EntityID string `json:"entity_id"` ExpireTime string `json:"expire_time"` ExplicitMaxTTL int `json:"explicit_max_ttl"` ExternalNamespacePolicies string `json:"external_namespace_policies"` IdentityPolicies []string `json:"identity_policies"` IssueTime string `json:"issue_time"` Meta *string `json:"meta"` NumUses int `json:"num_uses"` Orphan bool `json:"orphan"` Path string `json:"path"` Policies []string `json:"policies"` Renewable bool `json:"renewable"` TTL int `json:"ttl"` Type string `json:"type"` Period int `json:"period,omitempty"` LastRenewalTime int `json:"last_renewal_time,omitempty"` LastRenewal string `json:"last_renewal,omitempty"` }
type TokenSerializer ¶
type TokenSerializer struct { C *gin.Context TokenModel }
func (*TokenSerializer) Response ¶
func (s *TokenSerializer) Response() TokenResponse
Click to show internal directories.
Click to hide internal directories.