Documentation
¶
Overview ¶
Package config implements general handling for configuration files and adds definition for the configuration file YAML structure.
Index ¶
- func GetOrDefaultStringSlice(value []string, defaultValue []string) []string
- func Initialize(config *Config) error
- type Claim
- type Classification
- type Client
- type Config
- func (config *Config) GetAuthCookieName() string
- func (config *Config) GetClaims(username string, clientId string, scopes []string) []*Claim
- func (config *Config) GetClient(clientId string) (*Client, bool)
- func (config *Config) GetExpiredLoginMessage() string
- func (config *Config) GetFooterText() string
- func (config *Config) GetForwardAuthClient() (*Client, bool)
- func (config *Config) GetForwardAuthCookieName() string
- func (config *Config) GetForwardAuthEnabled() bool
- func (config *Config) GetForwardAuthEndpoint() string
- func (config *Config) GetForwardAuthParameterName() string
- func (config *Config) GetHideFooter() bool
- func (config *Config) GetHideLogo() bool
- func (config *Config) GetHtmlTitle() string
- func (config *Config) GetIntrospectScope() string
- func (config *Config) GetInvalidCredentialsMessage() string
- func (config *Config) GetIssuer(requestData *internalHttp.RequestData) string
- func (config *Config) GetLogoImage() *[]byte
- func (config *Config) GetMessageCookieName() string
- func (config *Config) GetOidc() bool
- func (config *Config) GetRevokeScope() string
- func (config *Config) GetServerSecret() string
- func (config *Config) GetSessionTimeoutSeconds() int
- func (config *Config) GetTitle() string
- func (config *Config) GetUser(username string) (*User, bool)
- func (config *Config) Validate() error
- type Cookies
- type ForwardAuth
- type Keys
- type Loader
- type ReadFile
- type Server
- type TLS
- type UI
- type Unmarshal
- type User
- type UserAddress
- type UserInformation
- type UserProfile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetOrDefaultStringSlice ¶
GetOrDefaultStringSlice returns an array or a default array if the given array is empty.
func Initialize ¶ added in v0.7.7
Initialize initializes a given Config. Checks for OIDC configuration on given Client entries. Initializes maps for faster Client and User access in the Config. Generates a server secret when none was provided. Loads a logo image into []byte to use in the web user interface. Checks for ForwardAuth settings. Sets the singleton for the current Config
Types ¶
type Classification ¶ added in v0.7.8
type Client ¶
type Client struct {
Id string `yaml:"id"`
ClientSecret string `yaml:"clientSecret"`
Salt string `yaml:"salt"`
Oidc bool `yaml:"oidc"`
AccessTTL int `yaml:"accessTTL"`
RefreshTTL int `yaml:"refreshTTL"`
IdTTL int `yaml:"idTTL"`
Introspect bool `yaml:"introspect"`
Revoke bool `yaml:"revoke"`
Redirects []string `yaml:"redirects"`
OpaqueToken bool `yaml:"opaqueToken"`
PasswordFallbackAllowed bool `yaml:"passwordFallbackAllowed"`
Audience []string `yaml:"audience"`
PrivateKey string `yaml:"privateKey"`
// contains filtered or unexported fields
}
Client defines the general client entry in the configuration.
func (*Client) GetAccessTTL ¶
GetAccessTTL returns access token time to live. When no time to live is provided a default value will be returned.
func (*Client) GetAudience ¶
GetAudience returns the audience value. When no audience value is provided a default value will be returned.
func (*Client) GetClientType ¶ added in v0.7.6
func (client *Client) GetClientType() oauth2.ClientType
GetClientType returns the client type value. When no client secret is provided the client will be a public client, confidential otherwise. See oauth2.ClientType
func (*Client) GetIdTTL ¶ added in v0.7.6
GetIdTTL returns id token time to live. When no time to live is provided a default value will be returned.
func (*Client) GetRefreshTTL ¶
GetRefreshTTL returns refresh token time to live. When no time to live is provided a default value will be returned.
func (*Client) ValidateRedirect ¶ added in v0.7.7
ValidateRedirect returns whether the redirect is valid for a given Client or not.
type Config ¶
type Config struct {
Server Server `yaml:"server"`
Clients []Client `yaml:"clients"`
Users []User `yaml:"users"`
UI UI `yaml:"ui"`
Classification []Classification `yaml:"classification"`
// contains filtered or unexported fields
}
Config defines the root entry for the configuration.
func GetConfigInstance ¶ added in v0.7.7
func GetConfigInstance() *Config
GetConfigInstance returns the current singleton of Config when it was initialized by Initialize before.
func (*Config) GetAuthCookieName ¶
GetAuthCookieName returns the name of the authentication cookie. When no name is provided a default value will be returned.
func (*Config) GetClaims ¶ added in v0.7.8
GetClaims returns an array of claims related to the username, client id and scopes.
func (*Config) GetClient ¶
GetClient returns a Client for the given clientId. Also returns a bool which indicates, whether the Client exists or not.
func (*Config) GetExpiredLoginMessage ¶ added in v0.7.7
GetExpiredLoginMessage returns the configured login expired message. When no login expired message is provided a default value will be returned.
func (*Config) GetFooterText ¶
GetFooterText returns whether the text shown in the footer of the web user interface. When no footer text is provided a default value will be returned.
func (*Config) GetForwardAuthClient ¶ added in v0.7.7
GetForwardAuthClient return a Client used for Traefik Forward Auth, also returns a bool indicating whether such a Client exists or not.
func (*Config) GetForwardAuthCookieName ¶ added in v0.7.8
GetForwardAuthCookieName returns the name of the authentication cookie for ForwardAuth. When no name is provided a default value will be returned.
func (*Config) GetForwardAuthEnabled ¶ added in v0.7.7
GetForwardAuthEnabled returns whether Traefik Forward Auth is enabled or not. Check in general whether the ForwardAuth ExternalUrl value is set.
func (*Config) GetForwardAuthEndpoint ¶ added in v0.7.7
GetForwardAuthEndpoint returns the endpoint which will use used for Traefik Forward Auth. When no endpoint is provided a default value will be returned.
func (*Config) GetForwardAuthParameterName ¶ added in v0.7.7
GetForwardAuthParameterName returns the query parameter name which will use used for Traefik Forward Auth. When no query parameter name is provided a default value will be returned.
func (*Config) GetHideFooter ¶
GetHideFooter returns whether the footer should be hidden in the web user interface.
func (*Config) GetHideLogo ¶ added in v0.7.7
GetHideLogo returns whether the logo should be hidden in the web user interface.
func (*Config) GetHtmlTitle ¶ added in v0.7.8
GetHtmlTitle returns whether the HTML title shown in the web user interface.
func (*Config) GetIntrospectScope ¶
GetIntrospectScope returns the scope which can be used to introspect tokens. When no scope is provided a default value will be returned.
func (*Config) GetInvalidCredentialsMessage ¶ added in v0.7.7
GetInvalidCredentialsMessage returns the configured invalid credentials message. When no invalid credentials message is provided a default value will be returned.
func (*Config) GetIssuer ¶ added in v0.7.7
func (config *Config) GetIssuer(requestData *internalHttp.RequestData) string
GetIssuer returns the issuer, either by mirroring from request, from Server configuration or default value.
func (*Config) GetLogoImage ¶ added in v0.7.7
GetLogoImage returns a pointer to the loaded logo image. Can be nil if no image was provided.
func (*Config) GetMessageCookieName ¶ added in v0.7.6
GetMessageCookieName returns the name of the message cookie. When no name is provided a default value will be returned.
func (*Config) GetOidc ¶ added in v0.7.6
GetOidc returns whether one of the existing clients has OIDC flag set or not.
func (*Config) GetRevokeScope ¶
GetRevokeScope returns the scope which can be used to revoke tokens. When no scope is provided a default value will be returned.
func (*Config) GetServerSecret ¶
GetServerSecret returns the server secret. When no secret is provided a previously generated value will be returned.
func (*Config) GetSessionTimeoutSeconds ¶
GetSessionTimeoutSeconds returns the session timeout in seconds. When no session timeout is provided a default value will be returned.
type Cookies ¶ added in v0.7.6
type Cookies struct {
AuthName string `yaml:"authName"`
MessageName string `yaml:"messageName"`
ForwardAuthName string `yaml:"forwardAuthName"`
}
Cookies defines the name for HTTP cookies used by STOPnik.
type ForwardAuth ¶ added in v0.7.7
type ForwardAuth struct {
Enabled bool `yaml:"enabled"`
Endpoint string `yaml:"endpoint"`
ExternalUrl string `yaml:"externalUrl"`
ParameterName string `yaml:"parameterName"`
Redirects []string `yaml:"redirects"`
}
ForwardAuth defines the configuration related to Traefik Forward Auth, only used when ExternalUrl is provided.
type Loader ¶
type Loader interface {
// LoadConfig loads the given configuration and validates if necessary.
LoadConfig(name string, validate bool) error
}
Loader defines how a configuration is loaded.
func NewConfigLoader ¶
NewConfigLoader combines the ReadFile and Unmarshal functions into a Loader.
type Server ¶
type Server struct {
LogLevel string `yaml:"logLevel"`
Addr string `yaml:"addr"`
Cookies Cookies `yaml:"cookies"`
Secret string `yaml:"secret"`
PrivateKey string `yaml:"privateKey"`
TLS TLS `yaml:"tls"`
LogoutRedirect string `yaml:"logoutRedirect"`
IntrospectScope string `yaml:"introspectScope"`
RevokeScope string `yaml:"revokeScopeScope"`
SessionTimeoutSeconds int `yaml:"sessionTimeoutSeconds"`
Issuer string `yaml:"issuer"`
ForwardAuth ForwardAuth `yaml:"forwardAuth"`
}
Server defines the main STOPnik server configuration.
type UI ¶
type UI struct {
HideLogo bool `yaml:"hideLogo"`
HtmlTitle string `yaml:"htmlTitle"`
Title string `yaml:"title"`
LogoImage string `yaml:"logoImage"`
InvalidCredentialsMessage string `yaml:"invalidCredentialsMessage"`
ExpiredLoginMessage string `yaml:"expiredLoginMessage"`
}
UI defines the general web user interface entry in the configuration.
type User ¶
type User struct {
Username string `yaml:"username"`
Password string `yaml:"password"`
Salt string `yaml:"salt"`
UserProfile UserProfile `yaml:"userProfile"`
UserInformation UserInformation `yaml:"userInformation"`
}
User defines the general user entry in the configuration.
func (*User) GetFormattedAddress ¶ added in v0.7.6
GetFormattedAddress return the formatted address for a User.
func (*User) GetPreferredUsername ¶ added in v0.7.6
GetPreferredUsername returns the preferred username for a given User, or just the username.
type UserAddress ¶ added in v0.7.6
type UserAddress struct {
Formatted string `json:"formatted,omitempty"`
Street string `yaml:"street" json:"street_address,omitempty"`
City string `yaml:"city" json:"locality,omitempty"`
PostalCode string `yaml:"postalCode" json:"postal_code,omitempty"`
Region string `yaml:"region" json:"region,omitempty"`
Country string `yaml:"country" json:"country,omitempty"`
}
UserAddress defines the address for a specific user, the definition provided in the YAML file will be mapped into values inside a JSON response.
type UserInformation ¶ added in v0.7.8
type UserInformation struct {
Email string `yaml:"email" json:"email,omitempty"`
EmailVerified bool `yaml:"emailVerified" json:"email_verified,omitempty"`
PhoneNumber string `yaml:"phoneNumber" json:"phone_number,omitempty"`
PhoneVerified bool `yaml:"phoneNumberVerified" json:"phone_number_verified,omitempty"`
Address *UserAddress `yaml:"address" json:"address,omitempty"`
}
type UserProfile ¶ added in v0.7.6
type UserProfile struct {
Subject string `json:"sub,omitempty"`
Name string `json:"name,omitempty"`
GivenName string `yaml:"givenName" json:"given_name,omitempty"`
MiddleName string `yaml:"middleName" json:"middle_name,omitempty"`
FamilyName string `yaml:"familyName" json:"family_name,omitempty"`
Nickname string `yaml:"nickname" json:"nickname,omitempty"`
PreferredUserName string `yaml:"preferredUserName" json:"preferred_username,omitempty"`
Gender string `yaml:"gender" json:"gender,omitempty"`
BirthDate string `yaml:"birthDate" json:"birthdate,omitempty"`
ZoneInfo string `yaml:"zoneInfo" json:"zoneinfo,omitempty"`
Locale string `yaml:"locale" json:"locale,omitempty"`
Website string `yaml:"website" json:"website,omitempty"`
Profile string `yaml:"profile" json:"profile,omitempty"`
Picture string `yaml:"picture" json:"picture,omitempty"`
UpdatedAt int64 `json:"updated_at,omitempty"`
}
UserProfile defines the profile for a specific user, the definition provided in the YAML file will be mapped into values inside a JSON response.