access_key

package
v1.6.5-rc34 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPrefixOrPartCount = errors.New("invalid prefix or part count")
	ErrBase64DecodeFailed       = errors.New("base64 decode failed")
	ErrInvalidContentsPartCount = errors.New("invalid part count of contents")
	ErrParseVersionFailed       = errors.New("parse version failed")
	ErrParseGenTsFailed         = errors.New("parse generate ts failed")
	ErrInvalidVersion           = errors.New("invalid version")
)

Functions

func DeleteByName

func DeleteByName(ctx context.Context, name string) error

func RouterRegister added in v1.4.6

func RouterRegister(r *kit.Router, name, desc string)

func Validate

func Validate(ctx context.Context, key string) (interface{}, error, bool)

Types

type AccessKeyContext

type AccessKeyContext struct {
	// Version integer version fixed field
	Version int
	// GenTS access key generated timestamp (utc,seconds)
	GenTS time.Time
	// Rand random part, length: gAccessKeyRandLength
	Rand string
}

func NewAccessKeyContext

func NewAccessKeyContext(version int) *AccessKeyContext

func NewDefaultAccessKeyContext

func NewDefaultAccessKeyContext() *AccessKeyContext

func (*AccessKeyContext) Equal

func (c *AccessKeyContext) Equal(v *AccessKeyContext) bool

func (AccessKeyContext) MarshalText

func (c AccessKeyContext) MarshalText() ([]byte, error)

func (*AccessKeyContext) Regenerate

func (c *AccessKeyContext) Regenerate()

func (*AccessKeyContext) UnmarshalText

func (c *AccessKeyContext) UnmarshalText(data []byte) (err error)

type CondArgs

type CondArgs struct {
	AccountID      types.SFID                    `name:"-"`
	Names          []string                      `in:"query" name:"name,omitempty"`
	ExpiredAtBegin types.Timestamp               `in:"query" name:"expiredAtBegin,omitempty"`
	ExpiredAtEnd   types.Timestamp               `in:"query" name:"expiredAtEnd,omitempty"`
	IdentityIDs    types.SFIDs                   `in:"query" name:"identityID,omitempty"`
	IdentityTypes  []enums.AccessKeyIdentityType `in:"query" name:"identityType,omitempty"`
}

func (*CondArgs) Condition

func (r *CondArgs) Condition() builder.SqlCondition

type CreateAccountAccessKeyReq

type CreateAccountAccessKeyReq = CreateReqBase

type CreateReq

type CreateReq struct {
	// IdentityID associated with a publisher, an account or other application
	IdentityID types.SFID `json:"identityID,omitempty"`
	// IdentityType associated type, default associated current account
	IdentityType enums.AccessKeyIdentityType `json:"identityType,default='1'"`
	CreateReqBase
}

type CreateReqBase

type CreateReqBase struct {
	// Name access token name
	Name string `json:"name"`
	// ExpirationDays access token valid in ExpirationDays, if 0 means token will not be expired.
	ExpirationDays int `json:"expirationDays,omitempty"`
	// Description access token description
	Desc string `json:"desc,omitempty"`
	// Privileges operator group access privileges
	Privileges GroupAccessPrivileges `json:"privileges,omitempty"`
}

type CreateRsp

type CreateRsp struct {
	Name         string                      `json:"name"`
	IdentityType enums.AccessKeyIdentityType `json:"identityType"`
	IdentityID   types.SFID                  `json:"identityID"`
	AccessKey    string                      `json:"accessKey"`
	Privileges   []*GroupMetaWithPrivilege   `json:"privileges"`
	ExpiredAt    *types.Timestamp            `json:"expiredAt,omitempty"`
	Desc         string                      `json:"desc,omitempty"`
}

func Create

func Create(ctx context.Context, r *CreateReq) (*CreateRsp, error)

type GroupAccessPrivilege added in v1.4.6

type GroupAccessPrivilege struct {
	Name string                 `json:"name"`
	Perm enums.AccessPermission `json:"perm"`
}

type GroupAccessPrivileges added in v1.4.6

type GroupAccessPrivileges []GroupAccessPrivilege

func (GroupAccessPrivileges) ConvToPrivilegeModel added in v1.4.6

func (gaps GroupAccessPrivileges) ConvToPrivilegeModel() models.GroupAccessPrivileges

type GroupMeta added in v1.4.6

type GroupMeta struct {
	GroupMetaBase
	Operators map[string]*OperatorMeta
}

type GroupMetaBase added in v1.4.6

type GroupMetaBase struct {
	Name string `json:"name"`
	Desc string `json:"desc"`
}

func OperatorGroupMetaList added in v1.4.6

func OperatorGroupMetaList() []*GroupMetaBase

type GroupMetaWithPrivilege added in v1.4.6

type GroupMetaWithPrivilege struct {
	GroupMetaBase
	Perm enums.AccessPermission `json:"perm"`
}

func ConvToGroupMetaWithPrivileges added in v1.4.6

func ConvToGroupMetaWithPrivileges(privileges models.GroupAccessPrivileges) []*GroupMetaWithPrivilege

type ListData

type ListData struct {
	Name       string                   `json:"name"`
	ExpiredAt  *types.Timestamp         `json:"expiredAt,omitempty"`
	LastUsed   *types.Timestamp         `json:"lastUsed,omitempty"`
	Privileges []GroupMetaWithPrivilege `json:"privileges,omitempty"`
	Desc       string                   `json:"desc,omitempty"`
	datatypes.OperationTimes
}

func GetByName added in v1.4.6

func GetByName(ctx context.Context, name string) (*ListData, error)

func NewListDataByModel added in v1.4.6

func NewListDataByModel(v *models.AccessKey) *ListData

type ListReq

type ListReq struct {
	CondArgs
	datatypes.Pager
}

type ListRsp

type ListRsp struct {
	Data  []*ListData `json:"data"`
	Total int64       `json:"total"`
}

func List

func List(ctx context.Context, r *ListReq) (*ListRsp, error)

type OperatorMeta added in v1.4.6

type OperatorMeta struct {
	OperatorID  string
	Summary     string
	Method      string
	Attr        enums.ApiOperatorAttr
	MinimalPerm enums.AccessPermission
}

type UpdateReq added in v1.4.6

type UpdateReq struct {
	ExpirationDays int                   `json:"expirationDays,omitempty"`
	Desc           string                `json:"desc,omitempty"`
	Privileges     GroupAccessPrivileges `json:"privileges,omitempty"`
}

type UpdateRsp added in v1.4.6

type UpdateRsp struct {
	Name         string                      `json:"name"`
	IdentityType enums.AccessKeyIdentityType `json:"identityType"`
	IdentityID   types.SFID                  `json:"identityID"`
	Privileges   []*GroupMetaWithPrivilege   `json:"privileges"`
	ExpiredAt    *types.Timestamp            `json:"expiredAt,omitempty"`
	LastUsed     *types.Timestamp            `json:"lastUsed,omitempty"`
	Desc         string                      `json:"desc,omitempty"`
}

func UpdateByName added in v1.4.6

func UpdateByName(ctx context.Context, name string, r *UpdateReq) (*UpdateRsp, error)

type WithOperatorAttr added in v1.4.6

type WithOperatorAttr interface {
	OperatorAttr() enums.ApiOperatorAttr
}

Jump to

Keyboard shortcuts

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