authtocontext

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AuthDetailsContextKey is a key used to store and retrieve the authentication details to/from the http request
	AuthDetailsContextKey ContextKey = "AuthDetails"
	// AuthDetailsSessionKey is a key used to store and retrieve the authentication details to/from the http session
	AuthDetailsSessionKey string = "AuthDetails"
)

Variables

This section is empty.

Functions

func New

func New() func(http.Handler) http.Handler

New returns a new AuthToContextMiddlewareHandler

Types

type AuthDetails

type AuthDetails struct {
	Authenticated bool     `json:"authenticated"`
	Username      string   `json:"username,omitempty"`
	UserID        uint     `json:"userId,omitempty"`
	AuthType      AuthType `json:"authType,omitempty"`
}

AuthDetails is a struct used for storing authentication details within the cookie store

func Get added in v0.3.0

func Get(r *http.Request) AuthDetails

type AuthType

type AuthType string

AuthType is a alias for string used for AuthTypeSession and AuthTypePassPassword AuthType is used to store the type of used authentication within AuthDetails

const (
	// AuthTypeSession is used to represent a session-authentication in AuthDetails
	AuthTypeSession AuthType = "Session"
	// AuthTypeAppPassword  used to represent a app-password-authentication in AuthDetails
	AuthTypeAppPassword AuthType = "AppPassword"
)

type ContextKey

type ContextKey string

ContextKey is a string-alias used for safe-usage of the context method

type MiddlewareHandler

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

MiddlewareHandler is a middleware for handling all possible authentication options and storing them into the context of the http request

func (MiddlewareHandler) ServeHTTP

func (m MiddlewareHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements the core functionality of this middleware

Jump to

Keyboard shortcuts

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