application

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenNotFound = errors.New("token not found")
	ErrInvalidToken  = errors.New("invalid token")
	ErrTokenExpired  = errors.New("token is expired")
)
View Source
var (
	PositionHeader = "header"
	PositionQuery  = "query"
	PositionBody   = "body"
)

Functions

func CheckPosition

func CheckPosition(position string) error

func CheckSkill

func CheckSkill(skill string) bool

func GetToken

func GetToken(ctx http_service.IHttpContext, tokenName string, position string) (string, bool)

func HideToken

func HideToken(ctx http_service.IHttpContext, tokenName string, position string)

Types

type Auth

type Auth struct {
	Type      string `json:"type" label:"鉴权类型" skip:""`
	Position  string `json:"position" label:"token位置" enum:"header,query,body"`
	TokenName string `json:"token_name" label:"token名称"`
}

type BaseConfig

type BaseConfig struct {
	// contains filtered or unexported fields
}

func (*BaseConfig) Config

func (a *BaseConfig) Config() interface{}

func (*BaseConfig) MarshalJSON

func (a *BaseConfig) MarshalJSON() ([]byte, error)

func (*BaseConfig) SetType

func (a *BaseConfig) SetType(typ reflect.Type) error

func (*BaseConfig) UnmarshalJSON

func (a *BaseConfig) UnmarshalJSON(bytes []byte) error

type IApp

type IApp interface {
	Id() string
	Name() string
	Labels() map[string]string
	Disable() bool
	IAppExecutor
}

type IAppExecutor

type IAppExecutor interface {
	Execute(ctx http_service.IHttpContext) error
}

type IAuth

type IAuth interface {
	ID() string
	Check(appID string, users []ITransformConfig) error
	Set(app IApp, users []ITransformConfig)
	Del(appID string)
	UserCount() int
	IAuthUser
}

type IAuthUser

type IAuthUser interface {
	Driver() string
	GetUser(ctx http_service.IHttpContext) (*UserInfo, bool)
}

type ITransformConfig

type ITransformConfig interface {
	Config() interface{}
	SetType(typ reflect.Type) error
}

type IUser

type IUser interface {
	Username() string
}

type IUserManager

type IUserManager interface {
	Get(name string) (*UserInfo, bool)
	Set(appID string, user []*UserInfo)
	Del(name string)
	Check(appID string, driver string, users []IUser) error
	DelByAppID(appID string)
	List() []*UserInfo
	Count() int
}

type User

type User struct {
	Labels         map[string]string `json:"labels" label:"用户标签"`
	Expire         int64             `json:"expire" label:"过期时间" format:"date-time"`
	HideCredential bool              `json:"hide_credential" label:"是否隐藏证书"`
}

type UserInfo

type UserInfo struct {
	Name           string
	Value          string
	Expire         int64
	HideCredential bool
	Labels         map[string]string
	TokenName      string
	Position       string
	App            IApp
}

type UserManager

type UserManager struct {
	// contains filtered or unexported fields
}

func NewUserManager

func NewUserManager() *UserManager

func (*UserManager) Check

func (u *UserManager) Check(appID string, driver string, users []IUser) error

func (*UserManager) Count

func (u *UserManager) Count() int

func (*UserManager) Del

func (u *UserManager) Del(name string)

func (*UserManager) DelByAppID

func (u *UserManager) DelByAppID(appID string)

func (*UserManager) Get

func (u *UserManager) Get(name string) (*UserInfo, bool)

func (*UserManager) List

func (u *UserManager) List() []*UserInfo

func (*UserManager) Set

func (u *UserManager) Set(appID string, users []*UserInfo)

Directories

Path Synopsis
jwt

Jump to

Keyboard shortcuts

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