tokens

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2023 License: MPL-2.0 Imports: 12 Imported by: 0

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

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 NewAccessor() (string, error)

func NewToken

func NewToken(tokenType string) (string, error)

func SaveOne

func SaveOne(data interface{}) error

func SeedDB

func SeedDB(c *common.Config) error

func TokenCreate

func TokenCreate(c *gin.Context)

func TokenDelete

func TokenDelete(c *gin.Context)

func TokenRegister

func TokenRegister(router *gin.RouterGroup)

func TokenRenew

func TokenRenew(c *gin.Context)

func TokenRetrieve

func TokenRetrieve(c *gin.Context)

func TokenSelfRenew

func TokenSelfRenew(c *gin.Context)

func TokenSelfRetrieve

func TokenSelfRetrieve(c *gin.Context)

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

func (*TokenLookupModelValidator) Bind

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

func (*TokenModelValidator) Bind

func (s *TokenModelValidator) Bind(c *gin.Context) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL