auth

package
v0.1.0-beta-3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MethodHookAuth settings.AuthMethod = "hook"

MethodHookAuth is used to identify hook auth.

View Source
const MethodJSONAuth settings.AuthMethod = "json"

MethodJSONAuth is used to identify json auth.

View Source
const MethodNoAuth settings.AuthMethod = "noauth"

MethodNoAuth is used to identify no auth.

View Source
const MethodOIDCAuth settings.AuthMethod = "oidc"

MethodOIDCAuth is used to identify oidc auth.

View Source
const MethodProxyAuth settings.AuthMethod = "proxy"

MethodProxyAuth is used to identify no auth.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auther

type Auther interface {
	// Auth is called to authenticate a request.
	Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error)
	// LoginPage indicates if this auther needs a login page.
	LoginPage() bool
}

Auther is the authentication interface.

type HookAuth

type HookAuth struct {
	Users    users.Store        `json:"-"`
	Settings *settings.Settings `json:"-"`
	Server   *settings.Server   `json:"-"`
	Cred     hookCred           `json:"-"`
	Fields   hookFields         `json:"-"`
	Command  string             `json:"command"`
}

HookAuth is a hook implementation of an Auther.

func (*HookAuth) Auth

func (a *HookAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error)

Auth authenticates the user via a json in content body.

func (*HookAuth) GetUser

func (a *HookAuth) GetUser(d *users.User) *users.User

GetUser returns a User filled with hook values or provided defaults

func (*HookAuth) GetValues

func (a *HookAuth) GetValues(s string)

GetValues creates a map with values from the key-value format string

func (*HookAuth) LoginPage

func (a *HookAuth) LoginPage() bool

LoginPage tells that hook auth requires a login page.

func (*HookAuth) RunCommand

func (a *HookAuth) RunCommand() (string, error)

RunCommand starts the hook command and returns the action

func (*HookAuth) SaveUser

func (a *HookAuth) SaveUser() (*users.User, error)

SaveUser updates the existing user or creates a new one when not found

type JSONAuth

type JSONAuth struct {
	ReCaptcha *ReCaptcha `json:"recaptcha" yaml:"recaptcha"`
}

JSONAuth is a json implementation of an Auther.

func (JSONAuth) Auth

func (a JSONAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error)

Auth authenticates the user via a json in content body.

func (JSONAuth) LoginPage

func (a JSONAuth) LoginPage() bool

LoginPage tells that json auth doesn't require a login page.

type NoAuth

type NoAuth struct{}

NoAuth is no auth implementation of auther.

func (NoAuth) Auth

func (a NoAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error)

Auth uses authenticates user 1.

func (NoAuth) LoginPage

func (a NoAuth) LoginPage() bool

LoginPage tells that no auth doesn't require a login page.

type OAuthClient

type OAuthClient struct {
	ClientID               string                `json:"clientID"`
	ClientSecret           string                `json:"clientSecret"`
	Issuer                 string                `json:"issuer"`
	RedirectURL            string                `json:"redirectURL"`
	RedirectURLAppendQuery bool                  `json:"redirectURLAppendQuery"`
	OAuth2Config           oauth2.Config         `json:"-"`
	Verifier               *oidc.IDTokenVerifier `json:"-"`
}

OAuthClient describes the oidc connector parameters.

func (*OAuthClient) HandleAuthCallback

func (o *OAuthClient) HandleAuthCallback(r *http.Request, usr users.Store, srv *settings.Server) (*users.User, error)

HandleAuthCallback manages code exchange and obtains the id token.

func (*OAuthClient) InitAuthFlow

func (o *OAuthClient) InitAuthFlow(w http.ResponseWriter, r *http.Request)

InitAuthFlow triggers the oidc authentication flow.

func (*OAuthClient) InitClient

func (o *OAuthClient) InitClient()

InitClient configures the connector via oidc discovery.

type OIDCAuth

type OIDCAuth struct {
	OIDC *OAuthClient `json:"oidc" yaml:"oidc"`
}

OIDCAuth is an Open ID Connect auther implementation.

func (OIDCAuth) Auth

func (a OIDCAuth) Auth(r *http.Request, usr users.Store, _ *settings.Settings, srv *settings.Server) (*users.User, error)

Auth is executed when the identity provider enters the callback phase of an oauth code flow.

func (OIDCAuth) LoginPage

func (a OIDCAuth) LoginPage() bool

LoginPage tells that oidc auth doesn't require a login page.

type ProxyAuth

type ProxyAuth struct {
	Header string `json:"header"`
}

ProxyAuth is a proxy implementation of an auther.

func (ProxyAuth) Auth

func (a ProxyAuth) Auth(r *http.Request, usr users.Store, stg *settings.Settings, srv *settings.Server) (*users.User, error)

Auth authenticates the user via an HTTP header.

func (ProxyAuth) LoginPage

func (a ProxyAuth) LoginPage() bool

LoginPage tells that proxy auth doesn't require a login page.

type ReCaptcha

type ReCaptcha struct {
	Host   string `json:"host"`
	Key    string `json:"key"`
	Secret string `json:"secret"`
}

ReCaptcha identifies a recaptcha connection.

func (*ReCaptcha) Ok

func (r *ReCaptcha) Ok(response string) (bool, error)

Ok checks if a reCaptcha responde is correct.

type Storage

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

Storage is a auth storage.

func NewStorage

func NewStorage(back StorageBackend, userStore *users.Storage) *Storage

NewStorage creates a auth storage from a backend.

func (*Storage) Get

func (s *Storage) Get(t settings.AuthMethod) (Auther, error)

Get wraps a StorageBackend.Get.

func (*Storage) Save

func (s *Storage) Save(a Auther) error

Save wraps a StorageBackend.Save.

type StorageBackend

type StorageBackend interface {
	Get(settings.AuthMethod) (Auther, error)
	Save(Auther) error
}

StorageBackend is a storage backend for auth storage.

Jump to

Keyboard shortcuts

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