auth

package
v0.0.0-...-8964234 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const RightsNone = 0
View Source
const (
	RightsUser = 1 << iota // in hex:0x1 - 1
)

Variables

View Source
var (
	ErrNoMethod     = iErr.NotFound(40001, "no method")
	ErrNoToken      = iErr.Unauthorized(40002, "no token")
	ErrNoPermission = iErr.Forbidden(40003, "no permission")
)
View Source
var RightsMap = map[string]int32{
	"RightsUser": RightsUser,
}

for example

Functions

func Check

func Check(uRights, sRights uint64) error

user - server

func GetToken

func GetToken(ctx context.Context) string

func ServerAuthWrapper

func ServerAuthWrapper(rights map[string]Auth) server.HandlerWrapper

Types

type Auth

type Auth struct {
	Rights                  uint64
	LogRequest, LogResponse bool
}

type User

type User struct {
	ID     int32
	Rights uint64
}

func GetUserByToken

func GetUserByToken(token string) (*User, error)

func ServerAuth

func ServerAuth(ctx context.Context, rights uint64) (*User, error)

func UserAuth

func UserAuth(ctx context.Context) (*User, error)

Jump to

Keyboard shortcuts

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