oalib

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthLevel

type AuthLevel uint

AuthLevel 权限等级 对于操作类权限 0 禁止执行 1 允许执行 对于资源类权限 0 相当于没有 1 有限读权限 2 读权限 3 创建权限 4 修改权限 5 删除权限 6 赋予其余人权限

const (
	AuthNone AuthLevel = 0
	AuthDo   AuthLevel = 1
	// AuthPart TODO: 临时权限
	AuthPart   AuthLevel = 1
	AuthRead   AuthLevel = 2
	AuthCreate AuthLevel = 3
	AuthUpdate AuthLevel = 4
	AuthDelete AuthLevel = 5
	AuthAll    AuthLevel = 6
)

func (AuthLevel) CanCreate

func (a AuthLevel) CanCreate() bool

func (AuthLevel) CanDelete

func (a AuthLevel) CanDelete() bool

func (AuthLevel) CanDo

func (a AuthLevel) CanDo() bool

func (AuthLevel) CanDoAny

func (a AuthLevel) CanDoAny() bool

func (AuthLevel) CanRead

func (a AuthLevel) CanRead() bool

func (AuthLevel) CanUpdate

func (a AuthLevel) CanUpdate() bool

func (AuthLevel) Upper

func (a AuthLevel) Upper(b AuthLevel) bool

type Config

type Config struct {
	Host string
	UUID string
	Key  []byte
}

func (*Config) Valid

func (c *Config) Valid() bool

type OA

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

func New

func New(c *Config) *OA

func (*OA) LoginUrl

func (oa *OA) LoginUrl() string

func (*OA) Parse

func (oa *OA) Parse(token string, payload jwt.PayloadInterface) (bool, error)

func (*OA) Ping

func (oa *OA) Ping() error

type PayLoad

type PayLoad struct {
	jwt.Payload
	ID   uint
	Auth []*SimpleAuth
}

PayLoad TODO:: roles 是否会造成token过大 ?

func (*PayLoad) GetAuth

func (p *PayLoad) GetAuth(ResourceID string, ResourceUUID ...string) AuthLevel

GetAuth resource_uuid 缺省或仅第一个有效 权限会被更高权限覆盖

func (*PayLoad) ParseToken added in v1.0.0

func (p *PayLoad) ParseToken(token string, key []byte) (bool, error)

type SimpleAuth

type SimpleAuth struct {
	RID string
	// 具体某个资源的id
	RUID  string
	Level AuthLevel
}

Jump to

Keyboard shortcuts

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