auth

package
v0.0.0-...-7fd3dae Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auther

type Auther interface {
	MustAuth(next httprouter.Handle) httprouter.Handle
}

Auther is an middleware interface used to restrict web handlers that either require authentication or already have authentication and redirect to the main handler.

func NewProxyAuth

func NewProxyAuth(header string, userCreator UserCreator) Auther

NewProxyAuth constructs a new proxy auther that uses a HTTP Header as the primary mechanism for authentication with the expetation that an external authentication system (like SSO or a Reverse Proxy) is already authentication

func NewSessionAuth

func NewSessionAuth(redirectURL string) Auther

NewSessionAuth ...

type ProxyAuth

type ProxyAuth struct {
	Header      string
	UserCreator UserCreator
}

ProxyAuth ...

func (*ProxyAuth) MustAuth

func (pa *ProxyAuth) MustAuth(next httprouter.Handle) httprouter.Handle

MustAuth returns the next handler in the chain if the configured HTTP header exists in the request (assumes trust from the proxy), storing the username in the session.

type SessionAuth

type SessionAuth struct {
	RedirectURL string
}

SessionAuth ...

func (*SessionAuth) MustAuth

func (sa *SessionAuth) MustAuth(next httprouter.Handle) httprouter.Handle

MustAuth returns the next handler in the chain if the session has already been authenticated otherwise redirects to the login page.

type UserCreator

type UserCreator interface {
	CreateUser(user string, req *http.Request) error
}

UserCreator is called by authentication implementations like the proxy auth that have their authentication handled by another system like a parent proxy or sso and require user accounts to be created on the fly. CreateUser therefore will take a username or unique-id and create the account if it doesn't already exist.

Jump to

Keyboard shortcuts

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