authn

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SaveUserAuthenticated

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

func SaveUserUnauthenticated

func SaveUserUnauthenticated(
	w http.ResponseWriter,
	r *http.Request,
	config *config.Config,
) 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.

A token can either be issued for a specific project id or for a user. In the case of a project id, we attach a service account to the context. In the case of a user, we attach that user to the context.

type AuthNFactory

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

AuthNFactory generates a middleware handler `AuthN`

func NewAuthNFactory

func NewAuthNFactory(
	config *config.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(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.

Jump to

Keyboard shortcuts

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