core

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 3 Imported by: 21

Documentation

Index

Constants

View Source
const (
	NotDelete = 0
	Deleted   = 1
)
View Source
const APINamespace = "auth.IAuthClient"
View Source
const AuthorizationHeader = "Authorization"
View Source
const BuildVersion = "1.15.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

Functions

func CtxGetName

func CtxGetName(ctx context.Context) (name string, exists bool)

func CtxGetTokenLocation

func CtxGetTokenLocation(ctx context.Context) (location string, exists bool)

func CtxWithName

func CtxWithName(ctx context.Context, name string) context.Context

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 CtxWithTokenLocation(ctx context.Context, token string) context.Context

func HasPerm

func HasPerm(ctx context.Context, defaultPerms []Permission, perm Permission) bool

func IsValid

func IsValid(perm Permission) bool

Types

type CtxKey

type CtxKey int

type DBPrefix

type DBPrefix = []byte

type LogField

type LogField = string
const (
	FieldName    LogField = "name"
	FieldIP      LogField = "ip"
	FieldLevel   LogField = "level"
	FieldSvcName LogField = "svcName"
	FieldSpanId  LogField = "spanId"
	FieldPreHost LogField = "preHost"
	FieldElapsed LogField = "elapsed"
	FieldToken   LogField = "token"
)

type Measurement

type Measurement = string
const (
	MTMethod Measurement = "method"
)

type Page

type Page struct {
	Skip  int64 `form:"skip" json:"skip"`
	Limit int64 `form:"limit" json:"limit"`
}

func (*Page) GetLimit

func (o *Page) GetLimit() int64

func (*Page) GetSkip

func (o *Page) GetSkip() int64

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 UserState

type UserState int
const (
	UserStateUndefined UserState = iota
	UserStateEnabled
	UserStateDisabled
)

For compatibility with older versions of the API

func (UserState) String

func (us UserState) String() string

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)

Jump to

Keyboard shortcuts

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