auth

package
v0.0.0-...-d6efe1e Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserID

func GetUserID(ctx context.Context) (string, error)

GetUserID returns the user id from the context.

func Middleware

func Middleware(authenticator Authenticator, db AuthDBProvider, log *logger.Log) func(next http.Handler) http.Handler

Types

type AuthDBProvider

type AuthDBProvider interface {
	GetUserByID(ctx context.Context, userID string) (store.User, error)
}

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (Claims, error)
}

type Claims

type Claims struct {
	Sub   string
	Email string
}

type LambdaAuthenticator

type LambdaAuthenticator struct{}

LambdaAuthenticator

func (*LambdaAuthenticator) Authenticate

func (l *LambdaAuthenticator) Authenticate(r *http.Request) (Claims, error)

type LocalAuth

type LocalAuth struct {
	UserID string
	Email  string
}

LocalAuth

func NewLocalAuth

func NewLocalAuth(userID, email string) *LocalAuth

func (*LocalAuth) Authenticate

func (l *LocalAuth) Authenticate(r *http.Request) (Claims, error)

Jump to

Keyboard shortcuts

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