auth

package
v0.0.0-...-932f842 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package auth is for authenticating web based users and sessions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSchema

func CreateSchema(ctx context.Context, conn *pgx.Conn) error

CreateSchema will create the auth schema and associated tables needed for this package to run

Types

type Auth

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

Auth contains the config

func NewAuth

func NewAuth(config *Config) *Auth

NewAuth creates, configures and returns a new Auth object

func (*Auth) AuthHandler

func (a *Auth) AuthHandler(access string, f http.HandlerFunc) http.HandlerFunc

AuthHandler wraps functions that need authentication before executing. If authentication fails, we return status 401 NotAuthorized.

type Config

type Config struct {
	Issuer             string             // what authority will be issuing the jwt tokens
	SecretPath         string             // path to the file with the secrets
	Router             *httprouter.Router // router used to add auth http endpoints
	AccessExpire       time.Duration      // how long before the access tokens will expire
	RefreshExpire      time.Duration      // how long before the refresh tokens will expire
	UserRate           time.Duration      // max rate that a user can make any auth request
	GlobalRate         time.Duration      // max rate that all users can make any auth request
	LimiterLogger      *logging.Logger    // the rate limiter logger
	DB                 *pgxpool.Pool      // database connection to retrieve stored auth data
	Log                *logging.Logger    // logger for logging auth state changes
	EnableRegistration bool               // feature flag to enable or disable new registration
}

Config stores the settings used for all auth requests

Jump to

Keyboard shortcuts

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