Documentation
¶
Index ¶
- Constants
- Variables
- func ParseOriginString(origin string) (string, error)
- func SetupTestCerts(t *testing.T) (string, string)
- type Config
- func (c *Config) Close()
- func (c *Config) GetAPIName() string
- func (c *Config) GetAPIRouteVersion() string
- func (c *Config) GetDBConfig() *cconfig.DBConfig
- func (c *Config) GetDBHost() string
- func (c *Config) GetDBName() string
- func (c *Config) GetDBPassword() string
- func (c *Config) GetDBPasswordPath() string
- func (c *Config) GetDBPort() int
- func (c *Config) GetDBUser() string
- func (c *Config) GetDPSConfig() dpsclient.Config
- func (c *Config) GetDPSEnabled() bool
- func (c *Config) GetEnvDev() bool
- func (c *Config) GetEnvDisconnected() bool
- func (c *Config) GetIssuersConfig() ([]IssuerConfig, error)
- func (c *Config) GetKeycloakBaseURL() string
- func (c *Config) GetKeycloakClientID() string
- func (c *Config) GetKeycloakClientSecret() string
- func (c *Config) GetKeycloakClientSecretPath() string
- func (c *Config) GetKeycloakEnabled() bool
- func (c *Config) GetKeycloakExternalBaseURL() string
- func (c *Config) GetKeycloakRealm() string
- func (c *Config) GetKeycloakServiceAccountEnabled() bool
- func (c *Config) GetLogLevel() string
- func (c *Config) GetMetricsConfig() *MetricsConfig
- func (c *Config) GetMetricsEnabled() bool
- func (c *Config) GetMetricsNamespace() string
- func (c *Config) GetMetricsPort() int
- func (c *Config) GetOrInitKeycloakConfig() (*cauth.KeycloakConfig, error)
- func (c *Config) GetOrInitTokenOriginConfig() *cauth.TokenOriginConfig
- func (c *Config) GetPathToConfig() string
- func (c *Config) GetRateLimiterBurst() int
- func (c *Config) GetRateLimiterConfig() *RateLimiterConfig
- func (c *Config) GetRateLimiterEnabled() bool
- func (c *Config) GetRateLimiterExpiresIn() int
- func (c *Config) GetRateLimiterRate() float64
- func (c *Config) GetSentryDSN() string
- func (c *Config) GetSiteConfig() *SiteConfig
- func (c *Config) GetSiteManagerEnabled() bool
- func (c *Config) GetSiteManagerEndpoint() string
- func (c *Config) GetSitePhoneHomeUrl() string
- func (c *Config) GetTemporalCaPath() string
- func (c *Config) GetTemporalCertPath() string
- func (c *Config) GetTemporalConfig() (*cconfig.TemporalConfig, error)
- func (c *Config) GetTemporalEncryptionKey() string
- func (c *Config) GetTemporalEncryptionKeyPath() string
- func (c *Config) GetTemporalHost() string
- func (c *Config) GetTemporalKeyPath() string
- func (c *Config) GetTemporalNamespace() string
- func (c *Config) GetTemporalPort() int
- func (c *Config) GetTemporalQueue() string
- func (c *Config) GetTemporalServerName() string
- func (c *Config) GetTemporalTlsEnabled() bool
- func (c *Config) GetTracingEnabled() bool
- func (c *Config) GetTracingServiceName() string
- func (c *Config) SetKeycloakBaseURL(value string)
- func (c *Config) SetKeycloakClientID(value string)
- func (c *Config) SetKeycloakClientSecret()
- func (c *Config) SetKeycloakClientSecretPath(value string)
- func (c *Config) SetKeycloakEnabled(value bool)
- func (c *Config) SetKeycloakExternalBaseURL(value string)
- func (c *Config) SetKeycloakRealm(value string)
- func (c *Config) SetKeycloakServiceAccountEnabled(value bool)
- func (c *Config) SetRateLimiterBurst(value int)
- func (c *Config) SetRateLimiterEnabled(value bool)
- func (c *Config) SetRateLimiterExpiresIn(value int)
- func (c *Config) SetRateLimiterRate(value float64)
- func (c *Config) SetSiteManagerEnabled(value bool)
- func (c *Config) SetSiteManagerEndpoint(value string)
- func (c *Config) SetSitePhoneHomeUrl(value string)
- func (c *Config) SetTemporalCaPath(value string)
- func (c *Config) SetTemporalCertPath(value string)
- func (c *Config) SetTemporalEncryptionKey()
- func (c *Config) SetTemporalEncryptionKeyPath(value string)
- func (c *Config) SetTemporalKeyPath(value string)
- func (c *Config) Validate()
- func (c *Config) ValidateIssuersConfig(issuers []IssuerConfig) error
- func (c *Config) ValidateKeycloakConfig() error
- func (c *Config) ValidatePowerProvisioningConfig() error
- func (c *Config) ValidateSiteConfig() error
- func (c *Config) WatchConfigFile()
- func (c *Config) WatchSecretFilePaths()
- type IssuerConfig
- type MetricsConfig
- type RateLimiterConfig
- type SiteConfig
Constants ¶
const ( // ConfigFilePath specifies the path to the config file, this contains the default path ConfigFilePath = "config.file" // ConfigFilePathEnv specifies the environment variable name for the config file path ConfigFilePathEnv = "CONFIG_FILE_PATH" // ConfigEnvDev specifies if the service is running in development mode ConfigEnvDev = "env.dev" // ConfigEnvDisconnected specifies if the service is running in disconnected mode ConfigEnvDisconnected = "env.disconnected" // ConfigAPIName specifies the name of the API ConfigAPIName = "api.name" // ConfigAPIRouteVersion specifies the version of the API ConfigAPIRouteVersion = "api.route.version" // ConfigLogLevel specifies the log level ConfigLogLevel = "log.level" // ConfigSentryDSN is the DSN for Sentry ConfigSentryDSN = "log.sentry.dsn" // ConfigDBHost specifies the host of the database ConfigDBHost = "db.host" // ConfigDBPort specifies the port of the database ConfigDBPort = "db.port" // ConfigDBName specifies the name of the database ConfigDBName = "db.name" // ConfigDBUser specifies the user of the database ConfigDBUser = "db.user" // ConfigDBPasswordPath specifies the path for file containing password of the database ConfigDBPasswordPath = "db.passwordPath" // ConfigDBPassword specifies the password of the database, not read from config file, rather from file specified by db.passwordPath ConfigDBPassword = "db.password" // ConfigTemporalHost specifies the hostname for Temporal ConfigTemporalHost = "temporal.host" // ConfigTemporalPort specifies the port for Temporal ConfigTemporalPort = "temporal.port" // ConfigTemporalServerName specifies the server name for Temporal ConfigTemporalServerName = "temporal.serverName" // ConfigTemporalNamespace specifies the namespace for Temporal ConfigTemporalNamespace = "temporal.namespace" // ConfigTemporalQueue specifies the queue for Temporal ConfigTemporalQueue = "temporal.queue" // ConfigTemporalTlsEnabled specifies if TLS should be used with Temporal ConfigTemporalTlsEnabled = "temporal.tls.enabled" // ConfigTemporalCertPath specifies the path for client cert ConfigTemporalCertPath = "temporal.tls.certPath" // ConfigTemporalKeyPath specifies the path for client key ConfigTemporalKeyPath = "temporal.tls.keyPath" // ConfigTemporalCaPath specifies the path for server CA cert ConfigTemporalCaPath = "temporal.tls.caPath" // ConfigTemporalEncryptionKey specifies the data encryption key for Temporal ConfigTemporalEncryptionKey = "temporal.encryptionKey" // ConfigTemporalEncryptionKeyPath specifies the path for file containing data encryption key for Temporal ConfigTemporalEncryptionKeyPath = "temporal.encryptionKeyPath" // ConfigSiteManagerEnabled is a feature flag for site manager ConfigSiteManagerEnabled = "siteManager.enabled" // ConfigSiteManagerEndpoint is the service endpoint for site manager ConfigSiteManagerEndpoint = "siteManager.svcEndpoint" // ConfigSitePhoneHomeUrl is a phone home url from the site ConfigSitePhoneHomeUrl = "site.phoneHomeUrl" // ConfigMetricsEnabled is a feature flag for Prometheus metrics ConfigMetricsEnabled = "metrics.enabled" // ConfigMetricsPort specifies the port for Prometheus metrics ConfigMetricsPort = "metrics.port" // ConfigMetricsNamespace specifies the prefix for every exposed metric name ConfigMetricsNamespace = "metrics.namespace" // ConfigTracingEnabled is a feature flag for tracing ConfigTracingEnabled = "tracing.enabled" // ConfigTracingServiceName is the name of the tracing service ConfigTracingServiceName = "tracing.serviceName" // ConfigKeycloakEnabled is a feature flag for Keycloak authentication ConfigKeycloakEnabled = "keycloak.enabled" // ConfigKeycloakBaseURL is the base URL of the Keycloak server ConfigKeycloakBaseURL = "keycloak.baseURL" // ConfigKeycloakExternalBaseURL is the external base URL of the Keycloak server ConfigKeycloakExternalBaseURL = "keycloak.externalBaseURL" // ConfigKeycloakRealm is the Keycloak realm name ConfigKeycloakRealm = "keycloak.realm" // ConfigKeycloakClientID is the Keycloak client ID ConfigKeycloakClientID = "keycloak.clientID" // ConfigKeycloakClientSecretPath is the path to the file containing the client secret ConfigKeycloakClientSecretPath = "keycloak.clientSecretPath" // ConfigKeycloakClientSecret is the client secret, read from the secret file ConfigKeycloakClientSecret = "keycloak.clientSecret" // ConfigKeycloakServiceAccountEnabled is a feature flag for service account support ConfigKeycloakServiceAccountEnabled = "keycloak.serviceAccount" // ConfigRateLimiterEnabled is a feature flag for rate limiter ConfigRateLimiterEnabled = "rateLimiter.enabled" // ConfigRateLimiterRate specifies the rate limit (requests per second) ConfigRateLimiterRate = "rateLimiter.rate" // ConfigRateLimiterBurst specifies the burst size ConfigRateLimiterBurst = "rateLimiter.burst" // ConfigRateLimiterExpiresIn specifies the expiration time in seconds ConfigRateLimiterExpiresIn = "rateLimiter.expiresIn" // ConfigDPSEnabled controls whether NICo makes direct DPS calls. ConfigDPSEnabled = "powerProvisioning.dps.enabled" // ConfigDPSEndpoint is the remote DPS gRPC endpoint. ConfigDPSEndpoint = "powerProvisioning.dps.endpoint" // ConfigDPSRequestTimeout bounds each direct DPS operation. ConfigDPSRequestTimeout = "powerProvisioning.dps.requestTimeout" // ConfigDPSTokenPath specifies the bearer-token secret file. ConfigDPSTokenPath = "powerProvisioning.dps.tokenPath" // ConfigDPSCAPath specifies the CA bundle used to authenticate DPS. ConfigDPSCAPath = "powerProvisioning.dps.tls.caPath" // ConfigDPSServerName optionally overrides TLS server-name verification. ConfigDPSServerName = "powerProvisioning.dps.tls.serverName" )
const DefaultMetricsNamespace = "nico_rest_api"
DefaultMetricsNamespace prefixes every metric this server exposes and matches its nico-rest-api Helm service name. Operators override it with metrics.namespace. Deliberately independent of api.name, which is the URL path segment callers route on and has no bearing on how these series are named.
const DefaultSitePhoneHomeUrl = "http://169.254.169.254/latest/meta-data/phone_home"
Variables ¶
var ( // ProjectRoot describes the folder path of this project ProjectRoot = filepath.Join(filepath.Dir(cur), "../..") )
Functions ¶
func ParseOriginString ¶
ParseOriginString converts a string origin to its string constant
Types ¶
type Config ¶
type Config struct {
sync.RWMutex
TokenOriginConfig *cauth.TokenOriginConfig
SiteConfig *SiteConfig
KeycloakConfig *cauth.KeycloakConfig
// contains filtered or unexported fields
}
Config represents configurations for the service
func (*Config) GetAPIName ¶
GetAPIName returns the name of the API
func (*Config) GetAPIRouteVersion ¶
GetAPIRouteVersion returns the version of the API
func (*Config) GetDBPassword ¶
GetDBPassword returns the password of the database
func (*Config) GetDBPasswordPath ¶
GetDBPasswordPath returns the path for file containing password of the database
func (*Config) GetDPSConfig ¶
GetDPSConfig returns connection settings for direct DPS calls.
func (*Config) GetDPSEnabled ¶
GetDPSEnabled reports whether NICo makes direct DPS calls.
func (*Config) GetEnvDisconnected ¶
GetEnvDisconnected returns if the service is running in disconnected mode
func (*Config) GetIssuersConfig ¶
func (c *Config) GetIssuersConfig() ([]IssuerConfig, error)
GetIssuersConfig returns the issuer configurations from the config file
func (*Config) GetKeycloakBaseURL ¶
GetKeycloakBaseURL gets the base URL for Keycloak
func (*Config) GetKeycloakClientID ¶
GetKeycloakClientID gets the client ID for Keycloak
func (*Config) GetKeycloakClientSecret ¶
GetKeycloakClientSecret gets the client secret for Keycloak
func (*Config) GetKeycloakClientSecretPath ¶
GetKeycloakClientSecretPath gets the client secret path for Keycloak
func (*Config) GetKeycloakEnabled ¶
GetKeycloakEnabled gets the enabled field for Keycloak
func (*Config) GetKeycloakExternalBaseURL ¶
GetKeycloakExternalBaseURL gets the external base URL for Keycloak
func (*Config) GetKeycloakRealm ¶
GetKeycloakRealm gets the realm for Keycloak
func (*Config) GetKeycloakServiceAccountEnabled ¶
GetKeycloakServiceAccountEnabled gets the service account enabled flag for Keycloak
func (*Config) GetLogLevel ¶
GetLogLevel returns the log level
func (*Config) GetMetricsConfig ¶
func (c *Config) GetMetricsConfig() *MetricsConfig
GetMetricsConfig returns the Metrics config
func (*Config) GetMetricsEnabled ¶
GetMetricsEnabled gets the enabled field for Metrics
func (*Config) GetMetricsNamespace ¶
GetMetricsNamespace gets the prefix applied to every exposed metric name. An explicitly empty value falls back to the default, since echoprometheus substitutes its own "echo" prefix for an empty one.
func (*Config) GetMetricsPort ¶
GetZincSearchPort gets the port for Metrics
func (*Config) GetOrInitKeycloakConfig ¶
func (c *Config) GetOrInitKeycloakConfig() (*cauth.KeycloakConfig, error)
GetOrInitKeycloakConfig gets the Keycloak configuration
func (*Config) GetOrInitTokenOriginConfig ¶
func (c *Config) GetOrInitTokenOriginConfig() *cauth.TokenOriginConfig
GetOrInitTokenOriginConfig returns the token origin config with all configured auth providers
func (*Config) GetPathToConfig ¶
GetPathToConfig returns the path to the config file
func (*Config) GetRateLimiterBurst ¶
GetRateLimiterBurst gets the burst size
func (*Config) GetRateLimiterConfig ¶
func (c *Config) GetRateLimiterConfig() *RateLimiterConfig
GetRateLimiterConfig returns the rate limiter config
func (*Config) GetRateLimiterEnabled ¶
GetRateLimiterEnabled gets the enabled field for rate limiter
func (*Config) GetRateLimiterExpiresIn ¶
GetRateLimiterExpiresIn gets the expiration time in seconds
func (*Config) GetRateLimiterRate ¶
GetRateLimiterRate gets the rate limit (requests per second)
func (*Config) GetSentryDSN ¶
GetSentryDSN returns the DSN for Sentry
func (*Config) GetSiteConfig ¶
func (c *Config) GetSiteConfig() *SiteConfig
GetSiteConfig returns the Site config
func (*Config) GetSiteManagerEnabled ¶
GetSiteManagerEnabled sets the enabled field
func (*Config) GetSiteManagerEndpoint ¶
GetSiteManagerEndpoint gets the path for site manager service endpoint
func (*Config) GetSitePhoneHomeUrl ¶
GetSitePhoneHomeUrl gets the url for PhoneHome
func (*Config) GetTemporalCaPath ¶
GetTemporalCaPath returns the path for ca cert for Temporal
func (*Config) GetTemporalCertPath ¶
GetTemporalCertPath returns the path for client cert for Temporal
func (*Config) GetTemporalConfig ¶
func (c *Config) GetTemporalConfig() (*cconfig.TemporalConfig, error)
GetTemporalConfig returns the temporal config
func (*Config) GetTemporalEncryptionKey ¶
GetTemporalEncryptionKey returns the encryption key for Temporal
func (*Config) GetTemporalEncryptionKeyPath ¶
GetTemporalEncryptionKeyPath returns the path for file containing encryption key for Temporal
func (*Config) GetTemporalHost ¶
GetTemporalHost returns the hostname for Temporal
func (*Config) GetTemporalKeyPath ¶
GetTemporalKeyPath returns the path for client key for Temporal
func (*Config) GetTemporalNamespace ¶
GetTemporalNamespace returns the namespace for Temporal
func (*Config) GetTemporalPort ¶
GetTemporalPort returns the port for Temporal
func (*Config) GetTemporalQueue ¶
GetTemporalQueue returns the queue for Temporal
func (*Config) GetTemporalServerName ¶
GetTemporalServerName returns the server name for Temporal
func (*Config) GetTemporalTlsEnabled ¶
GetTemporalTlsEnabled returns true if TLS is enabled for Temporal connection
func (*Config) GetTracingEnabled ¶
GetTracingEnabled gets the enabled field for tracing
func (*Config) GetTracingServiceName ¶
GetTracingServiceName gets the service name for tracing
func (*Config) SetKeycloakBaseURL ¶
SetKeycloakBaseURL sets the base URL for Keycloak
func (*Config) SetKeycloakClientID ¶
SetKeycloakClientID sets the client ID for Keycloak
func (*Config) SetKeycloakClientSecret ¶
func (c *Config) SetKeycloakClientSecret()
SetKeycloakClientSecret sets the client secret for Keycloak
func (*Config) SetKeycloakClientSecretPath ¶
SetKeycloakClientSecretPath sets the client secret path for Keycloak
func (*Config) SetKeycloakEnabled ¶
SetKeycloakEnabled sets the enabled field for Keycloak
func (*Config) SetKeycloakExternalBaseURL ¶
SetKeycloakExternalBaseURL sets the external base URL for Keycloak
func (*Config) SetKeycloakRealm ¶
SetKeycloakRealm sets the realm for Keycloak
func (*Config) SetKeycloakServiceAccountEnabled ¶
SetKeycloakServiceAccountEnabled sets the service account enabled flag for Keycloak
func (*Config) SetRateLimiterBurst ¶
SetRateLimiterBurst sets the burst size
func (*Config) SetRateLimiterEnabled ¶
SetRateLimiterEnabled sets the enabled field for rate limiter
func (*Config) SetRateLimiterExpiresIn ¶
SetRateLimiterExpiresIn sets the expiration time in seconds
func (*Config) SetRateLimiterRate ¶
SetRateLimiterRate sets the rate limit (requests per second)
func (*Config) SetSiteManagerEnabled ¶
SetSiteManagerEnabled sets the enabled field
func (*Config) SetSiteManagerEndpoint ¶
SetSiteManagerEndpoint sets the endpoint
func (*Config) SetSitePhoneHomeUrl ¶
SetSitePhoneHomeUrl sets the url for PhoneHome
func (*Config) SetTemporalCaPath ¶
SetTemporalCaPath sets the path for ca for Temporal
func (*Config) SetTemporalCertPath ¶
SetTemporalCertPath set the path for client cert for Temporal
func (*Config) SetTemporalEncryptionKey ¶
func (c *Config) SetTemporalEncryptionKey()
SetTemporalEncryptionKey sets the encryption key for Temporal
func (*Config) SetTemporalEncryptionKeyPath ¶
SetTemporalEncryptionKeyPath sets the path for file containing encryption key for Temporal
func (*Config) SetTemporalKeyPath ¶
SetTemporalKeyPath set the path for client key for Temporal
func (*Config) ValidateIssuersConfig ¶
func (c *Config) ValidateIssuersConfig(issuers []IssuerConfig) error
ValidateIssuersConfig validates the issuer configurations
func (*Config) ValidateKeycloakConfig ¶
ValidateKeycloakConfig validates the Keycloak configuration
func (*Config) ValidatePowerProvisioningConfig ¶
ValidatePowerProvisioningConfig validates settings required for direct DPS integration. DPS connection fields are ignored when integration is disabled.
func (*Config) ValidateSiteConfig ¶
ValidateSiteConfig validates Site configs
func (*Config) WatchConfigFile ¶
func (c *Config) WatchConfigFile()
WatchConfigFile starts watching the config file for reloadable setting changes.
func (*Config) WatchSecretFilePaths ¶
func (c *Config) WatchSecretFilePaths()
WatchSecretFilePaths starts watching secret files for changes.
type IssuerConfig ¶
type IssuerConfig struct {
Name string `mapstructure:"name"`
Origin string `mapstructure:"origin"` // String: "kas-legacy", "kas-ssa", "keycloak", "custom", "kas"
JWKS string `mapstructure:"jwks"`
Issuer string `mapstructure:"issuer"`
ServiceAccount bool `mapstructure:"serviceAccount"`
Audiences []string `mapstructure:"audiences"`
Scopes []string `mapstructure:"scopes"`
JWKSTimeout string `mapstructure:"jwksTimeout"` // e.g. "5s", "1m"
ClaimMappings []cauth.ClaimMapping `mapstructure:"claimMappings"`
AllowDuplicateStaticOrgNames bool `mapstructure:"allowDuplicateStaticOrgNames"` // When true, allows duplicate static org names across issuers
}
IssuerConfig represents a single issuer configuration entry This is the preferred configuration format that supports claim mappings
func (*IssuerConfig) GetAllowDuplicateStaticOrgNames ¶
func (ic *IssuerConfig) GetAllowDuplicateStaticOrgNames() bool
GetAllowDuplicateStaticOrgNames returns whether duplicate static org names are allowed Defaults to false (duplicates not allowed) if not specified
func (*IssuerConfig) GetJWKSTimeout ¶
func (ic *IssuerConfig) GetJWKSTimeout() (time.Duration, error)
GetJWKSTimeout parses and returns the JWKS timeout duration
func (*IssuerConfig) GetOrigin ¶
func (ic *IssuerConfig) GetOrigin() (string, error)
GetOrigin parses the origin and returns it as a string constant
func (*IssuerConfig) ValidateKasOrigin ¶
func (ic *IssuerConfig) ValidateKasOrigin() error
ValidateKasOrigin validates a KAS issuer configuration. The issuer carries the NGC API base URL the processor calls, so it is required rather than defaulted.
type MetricsConfig ¶
MetricsConfig holds configuration of Metrics
func NewMetricsConfig ¶
func NewMetricsConfig(enabled bool, port int, namespace string) *MetricsConfig
NewMetricsConfig initializes and returns a configuration object for managing Metrics
func (*MetricsConfig) GetListenAddr ¶
func (mcfg *MetricsConfig) GetListenAddr() string
GetListenAddr returns the local address for listen socket.
type RateLimiterConfig ¶
type RateLimiterConfig struct {
Enabled bool
Rate float64 // requests per second
Burst int // maximum burst size
ExpiresIn int // expiration time in seconds
}
RateLimiterConfig holds configuration for rate limiting
func NewRateLimiterConfig ¶
func NewRateLimiterConfig(enabled bool, rate float64, burst int, expiresIn int) *RateLimiterConfig
NewRateLimiterConfig initializes and returns a configuration object for rate limiting
type SiteConfig ¶
SiteConfig holds configuration for components and services running from site
func NewSiteConfig ¶
func NewSiteConfig(disconnected bool, phoneHomeUrl string) *SiteConfig
NewSiteConfig initializes and returns a configuration object for site