auth

package
v2.4.8 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidOIDCSecret = apperr.New("invalid_oidc_secret", apperr.WithTextTranslate(translator.Translate{translator.RU: "Не задан OIDC секрет", translator.EN: "OIDC secret not set"}))
)

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	Key             []byte     `json:"key,omitempty"`
	AccessTokenTTL  float64    `json:"access_token_ttl"`
	RefreshTokenTTL float64    `json:"refresh_token_ttl"`
	LDAP            []CfgLDAP  `json:"ldap"`
	SSO             CfgSSO     `json:"sso"`
	Limiter         CfgLimiter `json:"limiter"`
}

type CfgLDAP

type CfgLDAP struct {
	Domain string        `json:"key"`
	Addrs  []CfgLDAPAddr `json:"addrs"`
}

type CfgLDAPAddr

type CfgLDAPAddr struct {
	Addr    string `json:"addr"`
	Secured bool   `json:"secured"`
}

type CfgLimiter

type CfgLimiter struct {
	MaxAttempts int     `json:"max_attempts"`
	TTL         float64 `json:"ttl"`
}

type CfgOIDC

type CfgOIDC struct {
	ConfigURL         string   `json:"config_url"`
	ClientID          string   `json:"client_id"`
	ClientSecret      []byte   `json:"client_secret,omitempty"`
	RootURL           string   `json:"root_url"`
	LoginAttr         string   `json:"login_attr"`
	ValidRedirectURLs []string `json:"valid_redirect_urls"`
}

type CfgSAML

type CfgSAML struct {
	MetaDataFile      string   `json:"meta_data_file"`
	CertFile          string   `json:"cert_file"`
	KeyFile           string   `json:"key_file"`
	RootURL           string   `json:"root_url"`
	LoginAttr         string   `json:"login_attr"`
	ValidRedirectURLs []string `json:"valid_redirect_urls"`
}

type CfgSSO

type CfgSSO struct {
	Enabled string   `json:"enabled"`
	OIDC    *CfgOIDC `json:"oidc,omitempty"`
	SAML    *CfgSAML `json:"saml,omitempty"`
}

type Configurator

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

func NewConfigurator

func NewConfigurator() *Configurator

func (*Configurator) Action

func (c *Configurator) Action() string

func (*Configurator) AfterUpdate

func (c *Configurator) AfterUpdate(data []byte) error

func (*Configurator) Check

func (c *Configurator) Check(newData, lastData []byte) ([]byte, error)

func (*Configurator) Init

func (c *Configurator) Init() ([]byte, error)

func (*Configurator) Transform

func (c *Configurator) Transform(data []byte) ([]byte, error)

func (*Configurator) Unmarshal

func (c *Configurator) Unmarshal(data []byte) (any, error)

func (*Configurator) Watch

func (c *Configurator) Watch() <-chan Cfg

type Request

type Request struct {
	Key             *string  `json:"key" binding:"omitempty,min=8,max=256"`
	AccessTokenTTL  *float64 `json:"access_token_ttl" binding:"omitempty,min=1"`
	RefreshTokenTTL *float64 `json:"refresh_token_ttl" binding:"omitempty,min=1"`
	LDAP            []struct {
		Domain string `json:"domain" binding:"required,min=1,max=256"`
		Addrs  []struct {
			Addr    string `json:"addr" binding:"required,min=1,max=256"`
			Secured bool   `json:"secured"`
		} `json:"addrs" binding:"required,min=1,max=10,dive"`
	} `json:"ldap" binding:"omitempty,unique=Domain,dive"`
	SSO *struct {
		Enabled string `json:"enabled" binding:"required,oneof=oidc saml none"`
		OIDC    *struct {
			ConfigURL         string   `json:"config_url" binding:"required"`
			ClientID          string   `json:"client_id" binding:"required"`
			ClientSecret      *string  `json:"client_secret" binding:"omitempty,min=1"`
			RootURL           string   `json:"root_url" binding:"required,min=1,max=1024"`
			LoginAttr         string   `json:"login_attr" binding:"required"`
			ValidRedirectURLs []string `json:"valid_redirect_urls" binding:"required,max=10,dive,min=1,max=256"`
		} `json:"oidc,omitempty" binding:"required_if=Enabled oidc"`
		SAML *struct {
			RootURL           string   `json:"root_url" binding:"required,min=1,max=1024"`
			LoginAttr         string   `json:"login_attr" binding:"required"`
			ValidRedirectURLs []string `json:"valid_redirect_urls" binding:"required,max=10,dive,min=1,max=256"`
		} `json:"saml,omitempty" binding:"required_if=Enabled saml"`
	} `json:"sso" binding:"omitempty"`
	Limiter *struct {
		MaxAttempts int     `json:"max_attempts" binding:"required,min=1"`
		TTL         float64 `json:"ttl" binding:"required,min=1"`
	} `json:"limiter" binding:"omitempty"`
}

type Transformer

type Transformer struct {
	AccessTokenTTL  float64 `json:"access_token_ttl"`
	RefreshTokenTTL float64 `json:"refresh_token_ttl"`
	LDAP            []struct {
		Domain string `json:"key"`
		Addrs  []struct {
			Addr    string `json:"addr"`
			Secured bool   `json:"secured"`
		} `json:"addrs"`
	} `json:"ldap"`
	SSO *struct {
		Enabled string `json:"enabled"`
		OIDC    *struct {
			ConfigURL         string   `json:"config_url"`
			ClientID          string   `json:"client_id"`
			RootURL           string   `json:"root_url"`
			LoginAttr         string   `json:"login_attr"`
			ValidRedirectURLs []string `json:"valid_redirect_urls"`
		} `json:"oidc,omitempty"`
		SAML *struct {
			MetadataUploaded  bool     `json:"metadata_uploaded"`
			CertUploaded      bool     `json:"cert_uploaded"`
			KeyUploaded       bool     `json:"key_uploaded"`
			RootURL           string   `json:"root_url"`
			LoginAttr         string   `json:"login_attr"`
			ValidRedirectURLs []string `json:"valid_redirect_urls"`
		} `json:"saml,omitempty"`
	} `json:"sso"`
	Limiter *struct {
		MaxAttempts int     `json:"max_attempts"`
		TTL         float64 `json:"ttl"`
	} `json:"limiter"`
}

Jump to

Keyboard shortcuts

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