authentication

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AuthManager = &Manager{
	drivers:   make(map[string]DriverRegister),
	providers: make(map[string]AuthProvider),
	mu:        sync.RWMutex{},
}

AuthManager default manager

View Source
var DefaultCost = bcrypt.DefaultCost

Functions

func Compare

func Compare(hash, password []byte) bool

func Hash

func Hash(password []byte) ([]byte, error)

Types

type Attempter

type Attempter interface {
	Attempt(r contracts.RequestContract) (authenticate.User, error)
}

type AuthProvider

type AuthProvider interface {
	authenticate.UserProvider
	Attempter
}

type Config

type Config struct {
	Default string                 `yaml:"default"`
	Guards  map[string]GuardConfig `yaml:"guards"`
}

Config of authentication

type DriverRegister

type DriverRegister func(up AuthProvider, r contracts.RequestContract) (authenticate.Guard, error)

DriverRegister register of auth guard

type GuardConfig

type GuardConfig struct {
	Driver   string `yaml:"driver"`
	Provider string `yaml:"provider"`
}

GuardConfig config of auth guard

type Manager

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

Manager of authentication

func (*Manager) GetDriverRegister

func (m *Manager) GetDriverRegister(name string) (DriverRegister, bool)

GetDriverRegister get auth guard driver register

func (*Manager) GetGuard

func (m *Manager) GetGuard(driver, provider string, r contracts.RequestContract) (authenticate.Guard, error)

GetGuard get auth guard

func (*Manager) GetProvider

func (m *Manager) GetProvider(name string) (AuthProvider, bool)

GetProvider get auth provider

func (*Manager) RegisterDriver

func (m *Manager) RegisterDriver(name string, dr DriverRegister)

RegisterDriver register auth guard driver

func (*Manager) WithProvider

func (m *Manager) WithProvider(name string, p AuthProvider)

WithProvider register auth provider

type Service

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

func NewAuthService

func NewAuthService() *Service

func (*Service) Lifetime

func (s *Service) Lifetime(ioc container.Interface, request contracts.RequestContract)

Lifetime container callback usually register request lifetime instance to IoC-Container (per-request unique) this function will run before every request

func (*Service) Register

func (s *Service) Register(app *framework.App) error

Register service when app starting, before http server start you can configure service, initialize global vars etc. running at main goroutine

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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