config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CLAIM_TYPE_STRING      ClaimType = "string"
	CLAIM_TYPE_STRING_LIST           = "[]string"
	CLAIM_TYPE_NUMBER                = "number"
	CLAIM_TYPE_NUMBER_LIST           = "[]number"
)

Variables

View Source
var (
	DefaultScopes = ScopeConfig{
		"profile": []ClaimConfig{
			{Claim: "name", Attribute: "displayName", Type: "string"},
			{Claim: "given_name", Attribute: "givenName", Type: "string"},
			{Claim: "family_name", Attribute: "sn", Type: "string"},
		},
		"email": []ClaimConfig{
			{Claim: "email", Attribute: "mail", Type: "string"},
		},
		"phone": []ClaimConfig{
			{Claim: "phone_number", Attribute: "telephoneNumber", Type: "string"},
		},
		"groups": []ClaimConfig{
			{Claim: "groups", Attribute: "memberOf", Type: "[]string"},
		},
	}
)

Functions

func BindFlags

func BindFlags(vip *viper.Viper, flags *pflag.FlagSet)

func GetDCByDN

func GetDCByDN(dn string) (string, error)

func MappingClaims

func MappingClaims(attrs map[string][]string, maps map[string]ClaimConfig) map[string]interface{}

func TakeOptions

func TakeOptions(prefix string, typ reflect.Type, result map[string]string)

Types

type ClaimConfig

type ClaimConfig struct {
	Claim     string    `json:"claim"          yaml:"claim"          toml:"claim"`
	Attribute string    `json:"attribute"      yaml:"attribute"      toml:"attribute"`
	Type      ClaimType `json:"type,omitempty" yaml:"type,omitempty" toml:"type,omitempty"`
}

type ClaimType added in v0.4.0

type ClaimType string

func (ClaimType) Convert added in v0.4.0

func (t ClaimType) Convert(values []string) interface{}

func (ClaimType) String added in v0.4.0

func (t ClaimType) String() string

func (*ClaimType) UnmarshalText added in v0.4.0

func (t *ClaimType) UnmarshalText(text []byte) error

type ClientConfig

type ClientConfig struct {
	Name              string     `json:"name"                yaml:"name"                toml:"name"`
	IconURL           string     `json:"icon_url"            yaml:"icon_url"            toml:"icon_url"`
	Secret            string     `json:"secret"              yaml:"secret"              toml:"secret"`
	RedirectURI       PatternSet `json:"redirect_uri"        yaml:"redirect_uri"        toml:"redirect_uri"`
	CORSOrigin        PatternSet `json:"cors_origin"         yaml:"cors_origin"         toml:"cors_origin"`
	AllowImplicitFlow bool       `json:"allow_implicit_flow" yaml:"allow_implicit_flow" toml:"allow_implicit_flow"`
	RequestKey        string     `json:"request_key"         yaml:"request_key"         toml:"request_key"`
}

type ClientConfigSet added in v0.3.0

type ClientConfigSet map[string]ClientConfig

type Config

type Config struct {
	Issuer    *URL            `json:"issuer"              yaml:"issuer"              toml:"issuer"             flag:"issuer"`
	Listen    *TCPAddr        `json:"listen,omitempty"    yaml:"listen,omitempty"    toml:"listen,omitempty"   flag:"listen"`
	SignKey   string          `json:"sign_key,omitempty"  yaml:"sign_key,omitempty"  toml:"sign_key,omitempty" flag:"sign-key"`
	TLS       TLSConfig       `json:"tls,omitempty"       yaml:"tls,omitempty"       toml:"tls,omitempty"`
	LDAP      LDAPConfig      `json:"ldap"                yaml:"ldap"                toml:"ldap"`
	Expire    ExpireConfig    `json:"expire"              yaml:"expire"              toml:"expire"`
	Endpoints EndpointConfig  `json:"endpoint"            yaml:"endpoint"            toml:"endpoint"`
	Scopes    ScopeConfig     `json:"scope,omitempty"     yaml:"scope,omitempty"     toml:"scope,omitempty"`
	Clients   ClientConfigSet `json:"client,omitempty"    yaml:"client,omitempty"    toml:"client,omitempty"`
	Metrics   MetricsConfig   `json:"metrics"             yaml:"metrics"             toml:"metrics"`
	Templates TemplateConfig  `json:"template,omitempty"  yaml:"template,omitempty"  toml:"template,omitempty"`
}

func (*Config) AsJSON added in v0.3.0

func (c *Config) AsJSON() (string, error)

func (*Config) EndpointPaths

func (c *Config) EndpointPaths() ResolvedEndpointPaths

func (*Config) Load

func (c *Config) Load(file string, flags *pflag.FlagSet) error

func (*Config) OpenIDConfiguration

func (c *Config) OpenIDConfiguration() OpenIDConfiguration

func (*Config) ReadReader

func (c *Config) ReadReader(config io.Reader) error

func (*Config) Validate

func (c *Config) Validate() error

type Duration

type Duration time.Duration

func ParseDuration

func ParseDuration(text string) (Duration, error)

func (Duration) Duration added in v0.5.0

func (d Duration) Duration() time.Duration

func (Duration) IntSeconds

func (d Duration) IntSeconds() int64

func (Duration) MarshalText

func (d Duration) MarshalText() ([]byte, error)

func (*Duration) Set

func (d *Duration) Set(str string) error

func (Duration) StrSeconds

func (d Duration) StrSeconds() string

func (Duration) String

func (d Duration) String() string

func (Duration) Type

func (d Duration) Type() string

func (*Duration) UnmarshalText

func (d *Duration) UnmarshalText(text []byte) error

type EndpointConfig

type EndpointConfig struct {
	Authz    string `json:"authorization" yaml:"authorization" toml:"authorization" flag:"authz-endpoint"`
	Token    string `json:"token"         yaml:"token"         toml:"token"         flag:"token-endpoint"`
	Userinfo string `json:"userinfo"      yaml:"userinfo"      toml:"userinfo"      flag:"userinfo-endpoint"`
	Jwks     string `json:"jwks"          yaml:"jwks"          toml:"jwks"          flag:"jwks-uri"`
	Logout   string `json:"logout"        yaml:"logout"        toml:"logout"        flag:"logout-endpoint"`
}

type EnvReplacer

type EnvReplacer struct{}

func (EnvReplacer) Replace

func (r EnvReplacer) Replace(s string) string

type ExpireConfig

type ExpireConfig struct {
	Login   Duration `json:"login"   yaml:"login"   toml:"login"   flag:"login-expire"`
	Code    Duration `json:"code"    yaml:"code"    toml:"code"    flag:"code-expire"`
	Token   Duration `json:"token"   yaml:"token"   toml:"token"   flag:"token-expire"`
	Refresh Duration `json:"refresh" yaml:"refresh" toml:"refresh" flag:"refresh-expire"`
	SSO     Duration `json:"sso"     yaml:"sso"     toml:"sso"     flag:"sso-expire"`
}

type LDAPConfig

type LDAPConfig struct {
	Server      *URL   `json:"server"       yaml:"server"       toml:"server"       flag:"ldap"`
	User        string `json:"user"         yaml:"user"         toml:"user"         flag:"ldap-user"`
	Password    string `json:"password"     yaml:"password"     toml:"password"     flag:"ldap-password"`
	BaseDN      string `json:"base_dn"      yaml:"base_dn"      toml:"base_dn"      flag:"ldap-base-dn"`
	IDAttribute string `json:"id_attribute" yaml:"id_attribute" toml:"id_attribute" flag:"ldap-id-attribute"`
	DisableTLS  bool   `json:"disable_tls"  yaml:"disable_tls"  toml:"disable_tls"  flag:"ldap-disable-tls"`
}

type MetricsConfig

type MetricsConfig struct {
	Path     string `json:"path"               yaml:"path"               toml:"path"               flag:"metrics-path"`
	Username string `json:"username,omitempty" yaml:"username,omitempty" toml:"username,omitempty" flag:"metrics-username"`
	Password string `json:"password,omitempty" yaml:"password,omitempty" toml:"password,omitempty" flag:"metrics-password"`
}

type OpenIDConfiguration

type OpenIDConfiguration struct {
	Issuer                            string   `json:"issuer"`
	AuthorizationEndpoint             string   `json:"authorization_endpoint"`
	TokenEndpoint                     string   `json:"token_endpoint"`
	UserinfoEndpoint                  string   `json:"userinfo_endpoint"`
	JwksEndpoint                      string   `json:"jwks_uri"`
	EndSessionEndpoint                string   `json:"end_session_endpoint"`
	ScopesSupported                   []string `json:"scopes_supported"`
	ResponseTypesSupported            []string `json:"response_types_supported"`
	ResponseModesSupported            []string `json:"response_modes_supported"`
	GrantTypesSupported               []string `json:"grant_types_supported"`
	SubjectTypesSupported             []string `json:"subject_types_supported"`
	IDTokenSigningAlgValuesSupported  []string `json:"id_token_signing_alg_values_supported"`
	TokenEndpointAuthMethodsSupported []string `json:"token_endpoint_auth_methods_supported"`
	DisplayValuesSupported            []string `json:"display_values_supported"`
	ClaimsSupported                   []string `json:"claims_supported"`
	RequestParameterSupported         bool     `json:"request_parameter_supported"`
	RequestURIParameterSupported      bool     `json:"request_uri_parameter_supported"`
}

type ParseErrorSet

type ParseErrorSet []error

func (ParseErrorSet) Error

func (es ParseErrorSet) Error() string

type Pattern

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

func (Pattern) MarshalText

func (p Pattern) MarshalText() ([]byte, error)

func (Pattern) Match

func (p Pattern) Match(url string) bool

func (Pattern) String

func (p Pattern) String() string

func (*Pattern) UnmarshalText

func (p *Pattern) UnmarshalText(text []byte) error

type PatternSet

type PatternSet []Pattern

func (PatternSet) Match

func (ps PatternSet) Match(url string) bool

type ResolvedEndpointPaths

type ResolvedEndpointPaths struct {
	OpenIDConfiguration string
	Authz               string
	Token               string
	Userinfo            string
	Jwks                string
	Logout              string
}

type ScopeConfig

type ScopeConfig map[string][]ClaimConfig

func (ScopeConfig) AllClaims

func (sc ScopeConfig) AllClaims() []string

func (ScopeConfig) AttributesFor

func (sc ScopeConfig) AttributesFor(scopes []string) []string

func (ScopeConfig) ClaimMapFor

func (sc ScopeConfig) ClaimMapFor(scopes []string) map[string]ClaimConfig

func (ScopeConfig) ScopeNames

func (sc ScopeConfig) ScopeNames() []string

type TCPAddr

type TCPAddr net.TCPAddr

func DecideListenAddress

func DecideListenAddress(issuer *URL, listen *TCPAddr) *TCPAddr

func (*TCPAddr) MarshalText

func (a *TCPAddr) MarshalText() ([]byte, error)

func (*TCPAddr) Set

func (a *TCPAddr) Set(str string) error

func (*TCPAddr) String

func (a *TCPAddr) String() string

func (*TCPAddr) Type

func (a *TCPAddr) Type() string

func (*TCPAddr) UnmarshalText

func (a *TCPAddr) UnmarshalText(text []byte) error

type TLSConfig

type TLSConfig struct {
	Auto bool   `json:"auto,omitempty" yaml:"auto,omitempty" toml:"auto,omitempty" flag:"tls-auto"`
	Cert string `json:"cert,omitempty" yaml:"cert,omitempty" toml:"cert,omitempty" flag:"tls-cert"`
	Key  string `json:"key,omitempty"  yaml:"key,omitempty"  toml:"key,omitempty"  flag:"tls-key"`
}

type TemplateConfig

type TemplateConfig struct {
	LoginPage  string `json:"login_page,omitempty"  yaml:"login_page,omitempty"  toml:"login_page,omitempty"  flag:"login-page"`
	LogoutPage string `json:"logout_page,omitempty" yaml:"logout_page,omitempty" toml:"logout_page,omitempty" flag:"logout-page"`
	ErrorPage  string `json:"error_page,omitempty"  yaml:"error_page,omitempty"  toml:"error_page,omitempty"  flag:"error-page"`
}

type URL

type URL url.URL

func (*URL) Hostname added in v0.5.0

func (u *URL) Hostname() string

func (*URL) MarshalText

func (u *URL) MarshalText() ([]byte, error)

func (*URL) Set

func (u *URL) Set(str string) error

func (*URL) String

func (u *URL) String() string

func (*URL) Type

func (u *URL) Type() string

func (*URL) URL added in v0.5.0

func (u *URL) URL() *url.URL

func (*URL) UnmarshalText

func (u *URL) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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