filemanager: github.com/hacdias/filemanager/auth Index | Files

package auth

import "github.com/hacdias/filemanager/auth"

Index

Package Files

auth.go json.go none.go proxy.go storage.go

Constants

const MethodJSONAuth settings.AuthMethod = "json"

MethodJSONAuth is used to identify json auth.

const MethodNoAuth settings.AuthMethod = "noauth"

MethodNoAuth is used to identify no auth.

const MethodProxyAuth settings.AuthMethod = "proxy"

MethodProxyAuth is used to identify no auth.

type Auther Uses

type Auther interface {
    // Auth is called to authenticate a request.
    Auth(r *http.Request, s *users.Storage, root string) (*users.User, error)
    // LoginPage indicates if this auther needs a login page.
    LoginPage() bool
}

Auther is the authentication interface.

type JSONAuth Uses

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

JSONAuth is a json implementaion of an Auther.

func (JSONAuth) Auth Uses

func (a JSONAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error)

Auth authenticates the user via a json in content body.

func (JSONAuth) LoginPage Uses

func (a JSONAuth) LoginPage() bool

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

type NoAuth Uses

type NoAuth struct{}

NoAuth is no auth implementation of auther.

func (NoAuth) Auth Uses

func (a NoAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error)

Auth uses authenticates user 1.

func (NoAuth) LoginPage Uses

func (a NoAuth) LoginPage() bool

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

type ProxyAuth Uses

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

ProxyAuth is a proxy implementation of an auther.

func (ProxyAuth) Auth Uses

func (a ProxyAuth) Auth(r *http.Request, sto *users.Storage, root string) (*users.User, error)

Auth authenticates the user via an HTTP header.

func (ProxyAuth) LoginPage Uses

func (a ProxyAuth) LoginPage() bool

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

type ReCaptcha Uses

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

ReCaptcha identifies a recaptcha conenction.

func (*ReCaptcha) Ok Uses

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

Ok checks if a reCaptcha responde is correct.

type Storage Uses

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

Storage is a auth storage.

func NewStorage Uses

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

NewStorage creates a auth storage from a backend.

func (*Storage) Get Uses

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

Get wraps a StorageBackend.Get.

func (*Storage) Save Uses

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

Save wraps a StorageBackend.Save.

type StorageBackend Uses

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

StorageBackend is a storage backend for auth storage.

Package auth imports 8 packages (graph). Updated 2019-07-01. Refresh now. Tools for package owners.