auth

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound     = errors.New("user not found")
	ErrInvalidKey       = errors.New("invalid auth")
	ErrTokenParseFailed = errors.New("couldnt parse jwt")
	ErrTokenExpired     = errors.New("token expired")
)

Functions

This section is empty.

Types

type Options

type Options struct {
	Logger              *zap.Logger
	ForgeGenerateSecret bool
}

type Storage

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

func Init

func Init(db *database.DBModule, options Options) (*Storage, error)

func (*Storage) AddUser

func (db *Storage) AddUser(user string, key string, level UserLevel) error

func (*Storage) Authenticate

func (db *Storage) Authenticate(username string, key string, claims jwt.StandardClaims) (UserClaims, string, error)

func (*Storage) CountUsers

func (db *Storage) CountUsers() int

func (*Storage) DeleteUser

func (db *Storage) DeleteUser(user string) error

func (*Storage) GetUser

func (db *Storage) GetUser(username string) (User, bool)

func (*Storage) Verify added in v0.1.1

func (db *Storage) Verify(token string) (*UserClaims, error)

type User

type User struct {
	User    string    `json:"user"`
	AuthKey []byte    `json:"authkey"`
	Level   UserLevel `json:"level"`
}

type UserClaims

type UserClaims struct {
	User  string    `json:"user"`
	Level UserLevel `json:"level"`
	jwt.StandardClaims
}

type UserLevel

type UserLevel string
const (
	ULAdmin    UserLevel = "admin"
	ULStreamer UserLevel = "streamer"
)

type UserList

type UserList map[string]User

Jump to

Keyboard shortcuts

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