auth

package
v0.0.0-...-90a255e Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Providers             = map[string]*ProviderConfig{}
	UniqueDomainProviders = map[string]string{}
	FallbackProviders     []string
	ProviderHTTPBasic     ProviderType = "http_basic"
	ProviderHTTPHeader    ProviderType = "http_header"
	ProviderJWT           ProviderType = "jwt"
	ProviderLDAP          ProviderType = "ldap"
	ProviderUserPass      ProviderType = "userpass"
)

Functions

func HotLoadProviderConfigFile

func HotLoadProviderConfigFile(f string)

func HotLoadProviderRemote

func HotLoadProviderRemote(providerService string)

func LoadProviderConfigs

func LoadProviderConfigs(providers []*ProviderConfig) error

func RegisterProvider

func RegisterProvider(name string, provider *ProviderConfig)

func Valid

func Valid(state *smtp.ConnectionState, username, password string) error

Types

type HTTPBasicProvider

type HTTPBasicProvider struct {
	Meta         ProviderMeta `yaml:"meta" json:"meta"`
	URL          string       `yaml:"url" json:"url"`
	Method       string       `yaml:"method" json:"method"`
	SuccessCodes []int        `yaml:"success_codes" json:"success_codes"`
}

func (*HTTPBasicProvider) LoadParams

func (p *HTTPBasicProvider) LoadParams(params map[string]any) error

func (*HTTPBasicProvider) Remove

func (p *HTTPBasicProvider) Remove() error

func (*HTTPBasicProvider) Valid

func (p *HTTPBasicProvider) Valid(state *smtp.ConnectionState, username, password string) bool

type HTTPHeaderProvider

type HTTPHeaderProvider struct {
	Meta         ProviderMeta `yaml:"meta" json:"meta"`
	URL          string       `yaml:"url" json:"url"`
	Method       string       `yaml:"method" json:"method"`
	Header       string       `yaml:"header" json:"header"`
	SuccessCodes []int        `yaml:"success_codes" json:"success_codes"`
}

func (*HTTPHeaderProvider) LoadParams

func (p *HTTPHeaderProvider) LoadParams(params map[string]any) error

func (*HTTPHeaderProvider) Remove

func (p *HTTPHeaderProvider) Remove() error

func (*HTTPHeaderProvider) Valid

func (p *HTTPHeaderProvider) Valid(state *smtp.ConnectionState, username, password string) bool

type JWTProvider

type JWTProvider struct {
	Meta    ProviderMeta   `yaml:"meta" json:"meta"`
	JWKSURL string         `yaml:"jwks_url" json:"jwks_url"`
	Iss     string         `yaml:"iss" json:"iss"`
	Sub     string         `yaml:"sub" json:"sub"`
	Aud     string         `yaml:"aud" json:"aud"`
	Claims  map[string]any `yaml:"claims" json:"claims"`
	// contains filtered or unexported fields
}

func (*JWTProvider) LoadParams

func (p *JWTProvider) LoadParams(params map[string]any) error

func (*JWTProvider) NewJWKSProvider

func (p *JWTProvider) NewJWKSProvider() error

func (*JWTProvider) Remove

func (p *JWTProvider) Remove() error

func (*JWTProvider) Valid

func (p *JWTProvider) Valid(state *smtp.ConnectionState, username, password string) bool

func (*JWTProvider) ValidateJWT

func (p *JWTProvider) ValidateJWT(token string) bool

type LDAPProvider

type LDAPProvider struct {
	Meta                  ProviderMeta `yaml:"meta" json:"meta"`
	Server                string       `yaml:"server" json:"server"`
	Port                  int          `yaml:"port" json:"port"`
	EnableTLS             bool         `yaml:"enable_tls" json:"enable_tls"`
	TLSCa                 string       `yaml:"tls_ca" json:"tls_ca"`
	TLSCert               string       `yaml:"tls_cert" json:"tls_cert"`
	TLSKey                string       `yaml:"tls_key" json:"tls_key"`
	TLSInsecureSkipVerify bool         `yaml:"tls_insecure_skip_verify" json:"tls_insecure_skip_verify"`
	BindUser              string       `yaml:"bind_user" json:"bind_user"`
	BindPass              string       `yaml:"bind_pass" json:"bind_pass"`
	BaseDN                string       `yaml:"base_dn" json:"base_dn"`
	FilterString          string       `yaml:"filter_string" json:"filter_string"`
	Attributes            []string     `yaml:"attributes" json:"attributes"`
	// contains filtered or unexported fields
}

func (*LDAPProvider) Authenticate

func (p *LDAPProvider) Authenticate(username, password string) (bool, error)

Authenticate authenticates a user in LDAP

func (*LDAPProvider) Connect

func (p *LDAPProvider) Connect() (*ldap.Conn, error)

Connect connects to the LDAP server and returns the connection

func (*LDAPProvider) LDAPAuth

func (p *LDAPProvider) LDAPAuth(username, password string) (bool, error)

func (*LDAPProvider) LoadParams

func (p *LDAPProvider) LoadParams(params map[string]any) error

func (*LDAPProvider) Remove

func (p *LDAPProvider) Remove() error

func (*LDAPProvider) Search

func (p *LDAPProvider) Search(username string) (string, error)

Search searches LDAP for a user and returns DN if the user exists

func (*LDAPProvider) Valid

func (p *LDAPProvider) Valid(state *smtp.ConnectionState, username, password string) bool

type Provider

type Provider interface {
	Valid(state *smtp.ConnectionState, username, password string) bool
	LoadParams(params map[string]any) error
	Remove() error
}

func FallbackProviderFromRequest

func FallbackProviderFromRequest(state *smtp.ConnectionState, username, password string) (Provider, error)

func ProviderFromRequest

func ProviderFromRequest(state *smtp.ConnectionState, username, password string) (Provider, error)

type ProviderConfig

type ProviderConfig struct {
	Meta   ProviderMeta   `yaml:"meta" json:"meta"`
	Params map[string]any `yaml:"params" json:"params"`
	// contains filtered or unexported fields
}

func LoadProviderConfigFile

func LoadProviderConfigFile(f string) ([]*ProviderConfig, error)

func LoadProviderRemoteConfig

func LoadProviderRemoteConfig(providerService string) ([]*ProviderConfig, error)

func (*ProviderConfig) Load

func (p *ProviderConfig) Load() (*ProviderConfig, error)

type ProviderConfiguration

type ProviderConfiguration struct {
	Providers []*ProviderConfig `yaml:"providers" json:"providers"`
}

type ProviderMeta

type ProviderMeta struct {
	Name             string       `yaml:"name" json:"name"`
	Type             ProviderType `yaml:"type" json:"type"`
	Domain           string       `yaml:"domain" json:"domain"`
	UniqueDomainAuth bool         `yaml:"unique_domain_auth" json:"unique_domain_auth"`
	Fallback         bool         `yaml:"fallback" json:"fallback"`
}

type ProviderType

type ProviderType string

type UserPassProvider

type UserPassProvider struct {
	Meta     ProviderMeta `yaml:"meta" json:"meta"`
	Username string       `yaml:"username" json:"username"`
	Password string       `yaml:"password" json:"password"`
}

func (*UserPassProvider) LoadParams

func (p *UserPassProvider) LoadParams(params map[string]any) error

func (*UserPassProvider) Remove

func (p *UserPassProvider) Remove() error

func (*UserPassProvider) Valid

func (p *UserPassProvider) Valid(state *smtp.ConnectionState, username, password string) bool

Jump to

Keyboard shortcuts

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