auth

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthOriginDiscord = AuthOrigin("origin:discord")
	AuthOriginTwitch  = AuthOrigin("origin:twitch")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	RefreshTokenKey      string
	RefreshTokenLifetime time.Duration
	AccessTokenKey       string
	AccessTokenLifetime  time.Duration
}

type AuthHandler

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

func New

func New(
	config AuthConfig,
	publicAddress string,
	checkApiTokenHandler func(string) (string, error),
) (*AuthHandler, error)

func (AuthHandler) CheckAuth

func (t AuthHandler) CheckAuth(ctx *routing.Context) error

func (AuthHandler) CheckAuthRaw

func (t AuthHandler) CheckAuthRaw(authToken string) (Claims, error)

func (*AuthHandler) CheckScopes added in v1.5.0

func (t *AuthHandler) CheckScopes(must ...string) func(ctx *routing.Context) error

func (AuthHandler) HandleGetOtaQR

func (t AuthHandler) HandleGetOtaQR(ctx *routing.Context) error

func (AuthHandler) HandleLogin

func (t AuthHandler) HandleLogin(redirectPath string) func(ctx *routing.Context, claims Claims) error

func (AuthHandler) HandleLogout

func (t AuthHandler) HandleLogout(ctx *routing.Context) error

func (AuthHandler) HandleOTALogin

func (t AuthHandler) HandleOTALogin(ctx *routing.Context) error

func (AuthHandler) HandleRefresh

func (t AuthHandler) HandleRefresh(ctx *routing.Context) error

type AuthOrigin added in v1.5.0

type AuthOrigin string

type Claims

type Claims struct {
	jwt.PublicClaims

	UserID   string
	Username string
	Scopes   []string
}

func (Claims) IsAuthOrigin added in v1.5.0

func (t Claims) IsAuthOrigin(origin AuthOrigin) bool

type JWTHandler

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

func NewJWTHandler

func NewJWTHandler(key string, issuer string, lifetime time.Duration) (JWTHandler, error)

func (JWTHandler) Generate

func (t JWTHandler) Generate(claims Claims) (string, error)

func (JWTHandler) Lifetime

func (t JWTHandler) Lifetime() time.Duration

func (JWTHandler) Verify

func (t JWTHandler) Verify(token string) (Claims, error)

Jump to

Keyboard shortcuts

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