auth

package
v0.0.0-...-d450093 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) int

FromContext returnes the user id from a context that was called insinde the Middleware.

Types

type Auth

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

Auth authentivates a request using the whoami view.

func New

func New(cookieName string, secret string, backend Backend, configer Configer) *Auth

New creates a new Auth instance.

func (*Auth) Authenticate

func (a *Auth) Authenticate(r *http.Request) (context.Context, error)

Authenticate returns an context that can be used by auth.FromContext().

type Backend

type Backend interface {
	GetSession(sessionID string) ([]byte, error)
}

Backend gives the sessionData for a sessionID

type Configer

type Configer interface {
	ConfigValue(key string, v interface{}) error
}

Configer returns the value for a config name.

type Error

type Error string

Error is returned, when something goes wrong in the auth code.

func (Error) Error

func (e Error) Error() string

type Fake

type Fake int

Fake implements the http.Auther interface but always returns the same user id.

func (Fake) Authenticate

func (f Fake) Authenticate(r *http.Request) (context.Context, error)

Authenticate returns a context with the user id the Faker was initiaized with.

Jump to

Keyboard shortcuts

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