authn

package
v0.1.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveOAuthState

func SaveOAuthState(
	w http.ResponseWriter,
	r *http.Request,
	config *server.Config,
) (string, error)

func SaveUserAuthenticated

func SaveUserAuthenticated(
	w http.ResponseWriter,
	r *http.Request,
	config *server.Config,
	user *models.User,
	saveNew bool,
) (string, error)

func SaveUserUnauthenticated

func SaveUserUnauthenticated(
	w http.ResponseWriter,
	r *http.Request,
	config *server.Config,
) error

func ValidateOAuthState

func ValidateOAuthState(
	w http.ResponseWriter,
	r *http.Request,
	config *server.Config,
) (isValidated bool, isOAuthTriggered bool, err error)

Types

type AuthN

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

AuthN implements the authentication middleware

func (*AuthN) ServeHTTP

func (authn *AuthN) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP attaches an authenticated subject to the request context, or serves a forbidden error. If authenticated, it calls the next handler.

type AuthNBasic

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

AuthNBasic implements the authentication middleware

func (*AuthNBasic) ServeHTTP

func (authn *AuthNBasic) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP attaches an authenticated subject to the request context, or serves a forbidden error. If authenticated, it calls the next handler.

type AuthNBasicFactory

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

AuthNBasicFactory generates a middleware handler `AuthNBasic`

func NewAuthNBasicFactory

func NewAuthNBasicFactory(
	config *server.Config,
) *AuthNBasicFactory

NewAuthNBasicFactory returns an `AuthNBasicFactory` that uses the passed-in server config

func (*AuthNBasicFactory) NewAuthenticated

func (f *AuthNBasicFactory) NewAuthenticated(next http.Handler) http.Handler

NewAuthenticated creates a new instance of `AuthNBasic` that implements the http.Handler interface.

func (*AuthNBasicFactory) NewAuthenticatedWithRedirect

func (f *AuthNBasicFactory) NewAuthenticatedWithRedirect(requireEmailVerification bool, next http.Handler) http.Handler

NewAuthenticatedWithRedirect creates a new instance of `AuthNBasic` that implements the http.Handler interface. This handler redirects the user to login if the user is not attached, and stores a redirect URI in the session, if the session exists.

func (*AuthNBasicFactory) NewAuthenticatedWithoutEmailVerification

func (f *AuthNBasicFactory) NewAuthenticatedWithoutEmailVerification(next http.Handler) http.Handler

type AuthNFactory

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

AuthNFactory generates a middleware handler `AuthN`

func NewAuthNFactory

func NewAuthNFactory(
	config *server.Config,
) *AuthNFactory

NewAuthNFactory returns an `AuthNFactory` that uses the passed-in server config

func (*AuthNFactory) NewAuthenticated

func (f *AuthNFactory) NewAuthenticated(next http.Handler) http.Handler

NewAuthenticated creates a new instance of `AuthN` that implements the http.Handler interface.

func (*AuthNFactory) NewAuthenticatedWithRedirect

func (f *AuthNFactory) NewAuthenticatedWithRedirect(requireEmailVerification bool, next http.Handler) http.Handler

NewAuthenticatedWithRedirect creates a new instance of `AuthN` that implements the http.Handler interface. This handler redirects the user to login if the user is not attached, and stores a redirect URI in the session, if the session exists.

func (*AuthNFactory) NewAuthenticatedWithoutEmailVerification

func (f *AuthNFactory) NewAuthenticatedWithoutEmailVerification(next http.Handler) http.Handler

type NoAuthN

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

NoAuthN implements the authentication middleware

func (*NoAuthN) ServeHTTP

func (noauthn *NoAuthN) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP checks for credentials. If they exist, it throws bad request to the user.

type NoAuthNFactory

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

NoAuthNFactory generates a middleware handler `NoAuthN` which verifies that there are NO valid auth credentials attached to this request. This is useful for things like creating a new user or logging in.

func NewNoAuthNFactory

func NewNoAuthNFactory(
	config *server.Config,
) *NoAuthNFactory

NewNoAuthNFactory returns an `AuthNFactory` that uses the passed-in server config

func (*NoAuthNFactory) NewNotAuthenticated

func (f *NoAuthNFactory) NewNotAuthenticated(next http.Handler) http.Handler

NewNotAuthenticated creates a new instance of `NoAuthN` that implements the http.Handler interface.

Jump to

Keyboard shortcuts

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