auth

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAccessForbidden = errors.New("access forbidden")
View Source
var ErrTokenExpired = errors.New("token expired")

Functions

This section is empty.

Types

type AuthManager

type AuthManager interface {
	Authenticate(ctx context.Context, token string) (Principal, error)
}

type AuthMiddleware

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

func NewAuthMiddleware

func NewAuthMiddleware(authManager AuthManager, logger logger.Logger) *AuthMiddleware

func (*AuthMiddleware) RequireRoles

func (am *AuthMiddleware) RequireRoles(requiredRoles ...string) http.HandlerFunc

func (*AuthMiddleware) TokenAuth

func (am *AuthMiddleware) TokenAuth() http.HandlerFunc

type Principal

type Principal interface {
	GetID() string
	GetEmail() string
	GetRoles() []string
	GetClaims() map[string]interface{}
}

Principal defines the interface for authenticated user information.

type User

type User struct {
	ID       string
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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