auth

package
v0.0.0-...-5e8511f Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2023 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthHandler

func AuthHandler(handler AuthHandlerInterface) http.Handler

AuthHandler you'll want to chain this in if you want to make auth mandatory for the endpoint

func AuthMiddleware

func AuthMiddleware(authProvider *Provider, handler http.Handler) http.Handler

AuthMiddleware if auth should be optional and you want to do your own thing whenever the user is not logged in, use this

func GetUserFromRequest

func GetUserFromRequest(r *http.Request) *models.User

Types

type AuthHandlerInterface

type AuthHandlerInterface interface {
	Serve(user *models.User, w http.ResponseWriter, r *http.Request)
}

type Config

type Config struct {
	PrivateKey string `yaml:"private_key"`
}

func (*Config) Create

func (c *Config) Create(db *gorm.DB) (*Provider, error)

type Provider

type Provider struct {
	DB *gorm.DB
	// contains filtered or unexported fields
}

TODO make this all persistent

func (*Provider) Authenticate

func (p *Provider) Authenticate(user *models.User) (string, error)

func (*Provider) VerifyFromRequest

func (p *Provider) VerifyFromRequest(r *http.Request) (*models.User, error)

type UserClaims

type UserClaims struct {
	jwt.StandardClaims
	ID uint64
}

Jump to

Keyboard shortcuts

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