auth

package
v0.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2021 License: MIT Imports: 15 Imported by: 26

Documentation

Index

Constants

View Source
const (
	// 管理者
	PermAdmin = UserPerm("admin")
	// 會員
	PermMember = UserPerm("member")
	// 擁有
	PermOwner = UserPerm("owner")
	// 編輯
	PermEditor = UserPerm("editor")
	// 檢視
	PermViewer = UserPerm("viewer")
	// 訪客
	PermGuest = UserPerm("guest")
)
View Source
const (
	CtxUserInfoKey = util.CtxKey("userInfo")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessGuest added in v0.3.0

type AccessGuest interface {
	ReqUser
	GetSource() string
	GetSourceID() string
}

func NewAccessGuest added in v0.3.0

func NewAccessGuest(host, source, sid, acc, name, db, perm string) AccessGuest

type CompanyUser added in v0.3.0

type CompanyUser interface {
	ReqUser
	GetCompID() string
	GetComp() string
}

func GetCompUserInfo added in v0.3.0

func GetCompUserInfo(req *http.Request) CompanyUser

func NewCompUser added in v0.3.0

func NewCompUser(host, uid, acc, name, compID, comp, perm string) CompanyUser

type JwtConf

type JwtConf struct {
	PrivateKeyFile string `yaml:"privatekey"`
	PublicKeyFile  string `yaml:"publickey"`
	Header         struct {
		Alg string `yaml:"alg"`
		Typ string `yaml:"typ"`
		Kid string `yaml:"kid"`
	} `yaml:"header"`
	Claims struct {
		ExpDuration time.Duration `yaml:"exp"`
	} `yaml:"claims"`
	// contains filtered or unexported fields
}

func (*JwtConf) GetCompanyToken

func (j *JwtConf) GetCompanyToken(host, compID, compName, userID, acc, userName string, perm UserPerm) (*string, error)

func (*JwtConf) GetJwtAccessToken

func (j *JwtConf) GetJwtAccessToken(host string, source string, id interface{}, db string, perm UserPerm) (*string, error)

func (*JwtConf) GetKid

func (j *JwtConf) GetKid() string

func (*JwtConf) GetToken

func (j *JwtConf) GetToken(host string, data map[string]interface{}, exp uint8) (*string, error)

func (*JwtConf) ParseToken

func (j *JwtConf) ParseToken(tokenStr string) (*jwt.Token, error)

type JwtDI

type JwtDI interface {
	GetKid() string
}

type JwtToken

type JwtToken interface {
	GetToken(host string, data map[string]interface{}, exp uint8) (*string, error)
	ParseToken(tokenStr string) (*jwt.Token, error)
	// 對特定資源存取金鑰
	GetJwtAccessToken(host string, source string, id interface{}, db string, perm UserPerm) (*string, error)
	GetCompanyToken(host, compID, compName, userID, acc, userName string, perm UserPerm) (*string, error)
}

type ReqUser added in v0.3.0

type ReqUser interface {
	dao.LogUser
	Host() string
	GetId() string
	GetPerm() string
	GetDB() string
}

func GetUserInfo added in v0.3.0

func GetUserInfo(req *http.Request) ReqUser

func NewGuestUser added in v0.6.0

func NewGuestUser(host, ip string) ReqUser

func NewReqUser added in v0.3.0

func NewReqUser(host, uid, acc, name, perm string) ReqUser

type Totp

type Totp interface {
	GenerateCode() (string, error)
	ValidateCode(code string) (valid bool, err error)
	WriteQRCode(w io.Writer) error
	ShowInfo() error
}

func NewTotp

func NewTotp(host, account, secret string) Totp

type TransmitSecurity

type TransmitSecurity interface {
	GetAuthUrl(redirect string) string
	GetAccessToken(code, redirect string) (string, error)
	GetUserInfo(accessToken string) (string, error)
}

type TransmitSecurityConf

type TransmitSecurityConf struct {
	Host     string
	ClientId string `yaml:"clientId"`
	Secret   string `yaml:"clientSecret"`
}

func (*TransmitSecurityConf) GetAccessToken

func (c *TransmitSecurityConf) GetAccessToken(code, redirect string) (string, error)

func (*TransmitSecurityConf) GetAuthUrl

func (c *TransmitSecurityConf) GetAuthUrl(redirect string) string

func (*TransmitSecurityConf) GetUserInfo

func (c *TransmitSecurityConf) GetUserInfo(accessToken string) (string, error)

type UserPerm

type UserPerm string

func (UserPerm) Validate

func (up UserPerm) Validate() bool

Jump to

Keyboard shortcuts

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