Documentation ¶
Index ¶
- Constants
- Variables
- func CtxGetName(ctx context.Context) (name string, exists bool)
- func CtxGetTokenLocation(ctx context.Context) (location string, exists bool)
- func CtxWithName(ctx context.Context, name string) context.Context
- func CtxWithPerm(ctx context.Context, perm Permission) context.Context
- func CtxWithPerms(ctx context.Context, perms []Permission) context.Context
- func CtxWithTokenLocation(ctx context.Context, token string) context.Context
- func HasPerm(ctx context.Context, defaultPerms []Permission, perm Permission) bool
- func IsValid(perm Permission) bool
- type CtxKey
- type DBPrefix
- type LogField
- type Measurement
- type Page
- type Permission
- type UserState
- type ValueFromCtx
Constants ¶
View Source
const ( NotDelete = 0 Deleted = 1 )
View Source
const APINamespace = "auth.IAuthClient"
View Source
const AuthorizationHeader = "Authorization"
View Source
const BuildVersion = "1.16.0"
View Source
const EmptyString = ""
View Source
const VenusAPINamespaceHeader = "X-VENUS-API-NAMESPACE"
Variables ¶
View Source
var ( VerifyStateFailed = "failed" VerifyStateSuccess = "success" TagPerm = tag.MustNewKey("perm") TagUserState = tag.MustNewKey("user_state") TagTokenName = tag.MustNewKey("token_name") TagUserName = tag.MustNewKey("user_name") TagVerifyState = tag.MustNewKey("verify_state") )
View Source
var ( TokenGauge = metrics.NewInt64WithCategory("token/amount", "amount of token", emptyUnit) UserGauge = metrics.NewInt64WithCategory("user/amount", "amount of user", emptyUnit) TokenVerifyCounter = metrics.NewCounter("token/verify", "amount of token verify", TagPerm, TagVerifyState) ApiState = metrics.NewInt64("api/state", "api service state. 0: down, 1: up", emptyUnit) )
View Source
var CurrentCommit string
View Source
var PermArr = []Permission{ PermRead, PermWrite, PermSign, PermAdmin, }
View Source
var TagFields = []LogField{ FieldName, FieldIP, FieldLevel, FieldSvcName, }
View Source
var Version = BuildVersion + CurrentCommit
Functions ¶
func CtxGetTokenLocation ¶
func CtxWithPerm ¶
func CtxWithPerm(ctx context.Context, perm Permission) context.Context
func CtxWithPerms ¶
func CtxWithPerms(ctx context.Context, perms []Permission) context.Context
func CtxWithTokenLocation ¶
func HasPerm ¶
func HasPerm(ctx context.Context, defaultPerms []Permission, perm Permission) bool
func IsValid ¶
func IsValid(perm Permission) bool
Types ¶
type Permission ¶
type Permission = string
const ( // When changing these, update docs/API.md too PermRead Permission = "read" // default PermWrite Permission = "write" PermSign Permission = "sign" // Use wallet keys for signing PermAdmin Permission = "admin" // Manage permissions )
func AdaptOldStrategy ¶
func AdaptOldStrategy(perm Permission) []Permission
func CtxGetPerm ¶
func CtxGetPerm(ctx context.Context) ([]Permission, bool)
type ValueFromCtx ¶
type ValueFromCtx struct{}
func (*ValueFromCtx) AccFromCtx ¶
func (vfc *ValueFromCtx) AccFromCtx(ctx context.Context) (string, bool)
func (*ValueFromCtx) HostFromCtx ¶
func (vfc *ValueFromCtx) HostFromCtx(ctx context.Context) (string, bool)
Click to show internal directories.
Click to hide internal directories.