auth

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKey

func GenerateKey(length int) (string, error)

Types

type Auth

type Auth interface {
	Authorize(r *http.Request) (result []byte, user *User, err error)
	AuthorizeRequest(r *http.Request) (user *User, err error)
}

type JwtAuth

type JwtAuth struct {
	Path    string
	Options *JwtAuthOptions
}

func NewJwtAuth

func NewJwtAuth(filename string, adminName string) *JwtAuth

func (*JwtAuth) Authorize

func (auth *JwtAuth) Authorize(r *http.Request) (result []byte, user *User, err error)

func (*JwtAuth) AuthorizeRequest

func (auth *JwtAuth) AuthorizeRequest(r *http.Request) (*User, error)

func (*JwtAuth) GenerateToken

func (auth *JwtAuth) GenerateToken(u User) []byte

func (*JwtAuth) Load

func (auth *JwtAuth) Load(filename string) (err error)

func (*JwtAuth) Save

func (auth *JwtAuth) Save() error

func (*JwtAuth) ValidateUser

func (auth *JwtAuth) ValidateUser(user *User) bool

type JwtAuthOptions

type JwtAuthOptions struct {
	Secret []byte
	Users  []User
}

type NoAuth

type NoAuth struct{}

func (*NoAuth) Authorize

func (auth *NoAuth) Authorize(r *http.Request) (result []byte, user *User, err error)

func (*NoAuth) AuthorizeRequest

func (auth *NoAuth) AuthorizeRequest(r *http.Request) (user *User, err error)

type User

type User struct {
	Username string
	Password string
	Role     string
}

Jump to

Keyboard shortcuts

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