auth

package module
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 6 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// HTTP заголовок
	Header = "Authorization"
)
View Source
const LocalIdentityType = "LocalIdentity"

Variables

View Source
var (
	// Log --
	Log = log.NewFacility("stdhttp.auth")
)

Functions

func AddStdIdentityProvider added in v0.1.4

func AddStdIdentityProvider(provider IdentityProvider, aCfg *config.Auth) (err error)

func Hash

func Hash(p []byte, salt []byte) []byte

Hash --

Types

type Handler

type Handler interface {
	Init(lCfg *config.Listener) error
	Enabled() bool
	Score() int
	WWWAuthHeader() (name string, withRealm bool)
	Check(id uint64, prefix string, path string, w http.ResponseWriter, r *http.Request) (identity *Identity, tryNext bool, err error)
}

Handler --

type Handlers

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

Handlers --

func NewHandlers

func NewHandlers(cfg *config.Listener) *Handlers

NewHandlers --

func (*Handlers) Add

func (hh *Handlers) Add(ah Handler) (err error)

Add --

func (*Handlers) Check

func (hh *Handlers) Check(id uint64, prefix string, path string, permissions misc.BoolMap, w http.ResponseWriter, r *http.Request) (identity *Identity, code int, msg string)

Check --

func (*Handlers) Enabled

func (hh *Handlers) Enabled() bool

Enabled --

func (*Handlers) WriteAuthRequestHeaders

func (hh *Handlers) WriteAuthRequestHeaders(w http.ResponseWriter, prefix string, path string)

WriteAuthRequestHeaders --

type Identity

type Identity struct {
	Method   string
	User     string
	UserID   uint64
	UserGUID string
	Groups   []string
	Type     string
	IsAdmin  bool
	Extra    any
}

Identity --

func StdCheckUser added in v0.1.4

func StdCheckUser(u string, p string, hashedPassword bool) (identity *Identity, exists bool, err error)

func StdGetIdentity added in v0.1.4

func StdGetIdentity(u string) (identity *Identity, err error)

type IdentityProvider added in v0.1.4

type IdentityProvider interface {
	Init(aCfg *config.Auth) (err error)
	GetIdentity(u string) (identity *Identity, err error)
	Check(u string, p string, hashedPassword bool) (identity *Identity, exists bool, err error)
}

type LocalIdentityProvider added in v0.1.4

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

func (*LocalIdentityProvider) Check added in v0.1.4

func (provider *LocalIdentityProvider) Check(u string, p string, hashedPassword bool) (identity *Identity, exists bool, err error)

func (*LocalIdentityProvider) GetIdentity added in v0.1.4

func (provider *LocalIdentityProvider) GetIdentity(u string) (identity *Identity, err error)

func (*LocalIdentityProvider) Init added in v0.1.4

func (provider *LocalIdentityProvider) Init(aCfg *config.Auth) (err error)

Jump to

Keyboard shortcuts

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