configuration

package
v0.0.0-...-2d73068 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: Apache-2.0 Imports: 12 Imported by: 20

Documentation

Overview

Package configuration is in charge of the validation and extraction of all the configuration details from a configuration file.

Index

Constants

View Source
const (

	// RSAPrivateKey for signing JWT Tokens for service accounts
	// ssh-keygen -f auth_rsa
	DefaultServiceAccountPrivateKey = `` /* 1678-byte string literal not displayed */

	DefaultUserAccountPrivateKey = `` /* 1678-byte string literal not displayed */

	// DefaultValidRedirectURLs is a regex to be used to whitelist redirect URL for auth
	// If the AUTH_REDIRECT_VALID env var is not set then in Dev Mode all redirects allowed - *
	// In prod mode the following regex will be used by default:
	DefaultValidRedirectURLs = "" //"^(https|http)://(([^/?#]+[.])?(?i:openshift[.]io)|localhost)((/|:).*)?$" // *.openshift.io/* and localhost
	/* 140-byte string literal not displayed */

)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigurationData

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

ConfigurationData encapsulates the Viper configuration object which stores the configuration data in-memory.

func GetConfigurationData

func GetConfigurationData() (*ConfigurationData, error)

GetConfigurationData is a wrapper over NewConfigurationData which reads configuration file path from the environment variable.

func NewConfigurationData

func NewConfigurationData(mainConfigFile string, serviceAccountConfigFile string) (*ConfigurationData, error)

NewConfigurationData creates a configuration reader object using configurable configuration file paths

func (*ConfigurationData) DefaultConfigurationError

func (c *ConfigurationData) DefaultConfigurationError() error

DefaultConfigurationError returns an error if the default values is used for sensitive configuration like service account secrets or private keys. Error contains all the details. Returns nil if the default configuration is not used.

func (*ConfigurationData) GetAccessTokenExpiresIn

func (c *ConfigurationData) GetAccessTokenExpiresIn() int64

GetAccessTokenExpiresIn returns lifespan of user access tokens generated by Auth in seconds

func (*ConfigurationData) GetAdminConsoleServiceURL

func (c *ConfigurationData) GetAdminConsoleServiceURL() string

GetAdminConsoleServiceURL the URL to access to the Admin Console service

func (*ConfigurationData) GetAuthServiceURL

func (c *ConfigurationData) GetAuthServiceURL() string

GetAuthServiceUrl returns Auth Service URL

func (*ConfigurationData) GetCacheControlCollaborators

func (c *ConfigurationData) GetCacheControlCollaborators() string

GetCacheControlCollaborators returns the value to set in the "Cache-Control" HTTP response header when returning collaborators.

func (*ConfigurationData) GetCacheControlUser

func (c *ConfigurationData) GetCacheControlUser() string

GetCacheControlUser returns the value to set in the "Cache-Control" HTTP response header when data for the current user.

func (*ConfigurationData) GetCacheControlUsers

func (c *ConfigurationData) GetCacheControlUsers() string

GetCacheControlUsers returns the value to set in the "Cache-Control" HTTP response header when returning users.

func (*ConfigurationData) GetCheServiceURL

func (c *ConfigurationData) GetCheServiceURL() string

GetCheServiceURL returns the URL for the Che service

func (*ConfigurationData) GetClusterCacheRefreshInterval

func (c *ConfigurationData) GetClusterCacheRefreshInterval() time.Duration

func (*ConfigurationData) GetClusterServiceURL

func (c *ConfigurationData) GetClusterServiceURL() string

GetClusterServiceURL returns the short cluster service url "http://cluster" is the default URL

func (*ConfigurationData) GetDefaultConfigurationFile

func (c *ConfigurationData) GetDefaultConfigurationFile() string

GetDefaultConfigurationFile returns the default configuration file.

func (*ConfigurationData) GetDeprecatedServiceAccountPrivateKey

func (c *ConfigurationData) GetDeprecatedServiceAccountPrivateKey() ([]byte, string)

GetDeprecatedServiceAccountPrivateKey returns the deprecated service account private key (if any) and its ID that is used to verify service account authentication tokens during key rotation.

func (*ConfigurationData) GetDeprecatedUserAccountPrivateKey

func (c *ConfigurationData) GetDeprecatedUserAccountPrivateKey() ([]byte, string)

GetDeprecatedUserAccountPrivateKey returns the deprecated user account private key (if any) and its ID that is used to verify user access and refresh tokens during key rotation.

func (*ConfigurationData) GetDevModePublicKey

func (c *ConfigurationData) GetDevModePublicKey() (bool, []byte, string)

GetDevModePublicKey returns additional public key and its ID which should be used by the Auth service in Dev Mode For example a public key from Keycloak Returns false if in in Dev Mode

func (*ConfigurationData) GetEmailVerifiedRedirectURL

func (c *ConfigurationData) GetEmailVerifiedRedirectURL() string

GetEmailVerifiedRedirectURL returns the url where the user would be redirected to after clicking on email verification url

func (*ConfigurationData) GetEnvironment

func (c *ConfigurationData) GetEnvironment() string

GetEnvironment returns the current environment application is deployed in like 'production', 'prod-preview', 'local', etc as the value of environment variable `AUTH_ENVIRONMENT` is set.

func (*ConfigurationData) GetExpiredTokenRetentionHours

func (c *ConfigurationData) GetExpiredTokenRetentionHours() int

func (*ConfigurationData) GetGitHubClientDefaultScopes

func (c *ConfigurationData) GetGitHubClientDefaultScopes() string

GetGitHubClientDefaultScopes return default scopes used to link GitHub accounts

func (*ConfigurationData) GetGitHubClientID

func (c *ConfigurationData) GetGitHubClientID() string

GetGitHubClientID return GitHub client ID used to link GitHub accounts

func (*ConfigurationData) GetGitHubClientSecret

func (c *ConfigurationData) GetGitHubClientSecret() string

GetGitHubClientSecret return GitHub client secret used to link GitHub accounts

func (*ConfigurationData) GetHTTPAddress

func (c *ConfigurationData) GetHTTPAddress() string

GetHTTPAddress returns the HTTP address (as set via default, config file, or environment variable) that the auth server binds to (e.g. "0.0.0.0:8089")

func (*ConfigurationData) GetHeaderMaxLength

func (c *ConfigurationData) GetHeaderMaxLength() int64

GetHeaderMaxLength returns the max length of HTTP headers allowed in the system For example it can be used to limit the size of bearer tokens returned by the api service

func (*ConfigurationData) GetIgnoreEmailInProd

func (c *ConfigurationData) GetIgnoreEmailInProd() string

GetIgnoreEmailInProd returns regex for checking if the user with such email should be ignored during account provisioning

func (*ConfigurationData) GetInternalUsersEmailAddressSuffix

func (c *ConfigurationData) GetInternalUsersEmailAddressSuffix() string

GetInternalUsersEmailAddressSuffix returns the email address suffix of employees who can opt-in for the 'internal' features.

func (*ConfigurationData) GetInvitationAcceptedRedirectURL

func (c *ConfigurationData) GetInvitationAcceptedRedirectURL() string

func (*ConfigurationData) GetLogLevel

func (c *ConfigurationData) GetLogLevel() string

GetLogLevel returns the logging level (as set via config file or environment variable)

func (*ConfigurationData) GetMaxUsersListLimit

func (c *ConfigurationData) GetMaxUsersListLimit() int

GetMaxUsersListLimit returns the max number of users returned when searching users

func (*ConfigurationData) GetMetricsHTTPAddress

func (c *ConfigurationData) GetMetricsHTTPAddress() string

GetMetricsHTTPAddress returns the address the /metrics endpoing will be mounted. By default GetMetricsHTTPAddress is the same as GetHTTPAddress

func (*ConfigurationData) GetNotApprovedRedirect

func (c *ConfigurationData) GetNotApprovedRedirect() string

GetNotApprovedRedirect returns the URL to redirect to if the user is not approved May return empty string which means an unauthorized error should be returned instead of redirecting the user

func (*ConfigurationData) GetNotificationServiceURL

func (c *ConfigurationData) GetNotificationServiceURL() string

GetNotificationServiceURL returns the URL for the Notification service used for event notification

func (*ConfigurationData) GetOAuthProviderClientID

func (c *ConfigurationData) GetOAuthProviderClientID() string

GetOAuthClientID returns the oauth client ID (as set via config file or environment variable) that is used to make authorized API Calls to the OAuth authentication provider.

func (*ConfigurationData) GetOAuthProviderClientSecret

func (c *ConfigurationData) GetOAuthProviderClientSecret() string

GetOAuthProviderClientSecret returns the oauth client secret (as set via config file or environment variable) that is used to make authorized API Calls to the OAuth authentication provider.

func (*ConfigurationData) GetOAuthProviderEndpointAuth

func (c *ConfigurationData) GetOAuthProviderEndpointAuth() string

GetOAuthProviderEndpointAuth returns the auth provider endpoint set via config file or environment variable. If nothing set then in Dev environment the default endpoint will be returned. In producion the endpoint will be calculated from the request by replacing the last domain/host name in the full host name. Example: api.service.domain.org -> sso.service.domain.org or api.domain.org -> sso.domain.org

func (*ConfigurationData) GetOAuthProviderEndpointLogout

func (c *ConfigurationData) GetOAuthProviderEndpointLogout() string

GetOAuthProviderEndpointLogout returns the auth provider logout endpoint set via config file or environment variable. If nothing set then in Dev environment the default endpoint will be returned. In producion the endpoint will be calculated from the request by replacing the last domain/host name in the full host name. Example: api.service.domain.org -> sso.service.domain.org or api.domain.org -> sso.domain.org

func (*ConfigurationData) GetOAuthProviderEndpointToken

func (c *ConfigurationData) GetOAuthProviderEndpointToken() string

GetOAuthProviderEndpointToken returns the auth provider token endpoint set via config file or environment variable. If nothing set then in Dev environment the default endpoint will be returned. In producion the endpoint will be calculated from the request by replacing the last domain/host name in the full host name. Example: api.service.domain.org -> sso.service.domain.org or api.domain.org -> sso.domain.org

func (*ConfigurationData) GetOAuthProviderEndpointUserInfo

func (c *ConfigurationData) GetOAuthProviderEndpointUserInfo() string

GetOAuthProviderEndpointUserInfo returns the auth provider userinfo endpoint set via config file or environment variable. If nothing set then in Dev environment the default endpoint will be returned. In producion the endpoint will be calculated from the request by replacing the last domain/host name in the full host name. Example: api.service.domain.org -> sso.service.domain.org or api.domain.org -> sso.domain.org

func (*ConfigurationData) GetOAuthProviderType

func (c *ConfigurationData) GetOAuthProviderType() string

func (*ConfigurationData) GetOAuthStateReferencesCleanupEnabled

func (c *ConfigurationData) GetOAuthStateReferencesCleanupEnabled() bool

GetOAuthStateReferencesCleanupEnabled returns the interval between 2 cycles of the user deactivation notification worker.

func (*ConfigurationData) GetOAuthStateReferencesCleanupWorkerInterval

func (c *ConfigurationData) GetOAuthStateReferencesCleanupWorkerInterval() time.Duration

GetOAuthStateReferencesCleanupWorkerInterval returns the interval between 2 cycles of the OAuth state referencec cleanup.

func (*ConfigurationData) GetOSORegistrationAppAdminToken

func (c *ConfigurationData) GetOSORegistrationAppAdminToken() string

GetOSORegistrationAppAdminToken returns the admin token used to access OpenShift Online Registration App

func (*ConfigurationData) GetOSORegistrationAppAdminUsername

func (c *ConfigurationData) GetOSORegistrationAppAdminUsername() string

GetOSORegistrationAppAdminUsername returns the admin username used to access OpenShift Online Registration App

func (*ConfigurationData) GetOSORegistrationAppURL

func (c *ConfigurationData) GetOSORegistrationAppURL() string

GetOSORegistrationAppURL returns the URL for the OpenShift Online Registration App

func (*ConfigurationData) GetOpenShiftClientApiUrl

func (c *ConfigurationData) GetOpenShiftClientApiUrl() string

GetOpenShiftClientApiUrl return the default OpenShift cluster client API URL. If in a staging env a new user doesn't have the cluster set then this default cluster is used

func (*ConfigurationData) GetPodName

func (c *ConfigurationData) GetPodName() string

GetPodName returns the name of the pod on which this instance is running

func (*ConfigurationData) GetPostgresConfigString

func (c *ConfigurationData) GetPostgresConfigString() string

GetPostgresConfigString returns a ready to use string for usage in sql.Open()

func (*ConfigurationData) GetPostgresConnectionMaxIdle

func (c *ConfigurationData) GetPostgresConnectionMaxIdle() int

GetPostgresConnectionMaxIdle returns the number of connections that should be keept alive in the database connection pool at any given time. -1 represents no restrictions/default behavior

func (*ConfigurationData) GetPostgresConnectionMaxOpen

func (c *ConfigurationData) GetPostgresConnectionMaxOpen() int

GetPostgresConnectionMaxOpen returns the max number of open connections that should be open in the database connection pool. -1 represents no restrictions/default behavior

func (*ConfigurationData) GetPostgresConnectionRetrySleep

func (c *ConfigurationData) GetPostgresConnectionRetrySleep() time.Duration

GetPostgresConnectionRetrySleep returns the number of seconds (as set via default, config file, or environment variable) to wait before trying to connect again

func (*ConfigurationData) GetPostgresConnectionTimeout

func (c *ConfigurationData) GetPostgresConnectionTimeout() int64

GetPostgresConnectionTimeout returns the postgres connection timeout as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresDatabase

func (c *ConfigurationData) GetPostgresDatabase() string

GetPostgresDatabase returns the postgres database as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresHost

func (c *ConfigurationData) GetPostgresHost() string

GetPostgresHost returns the postgres host as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresPassword

func (c *ConfigurationData) GetPostgresPassword() string

GetPostgresPassword returns the postgres password as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresPort

func (c *ConfigurationData) GetPostgresPort() int64

GetPostgresPort returns the postgres port as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresSSLMode

func (c *ConfigurationData) GetPostgresSSLMode() string

GetPostgresSSLMode returns the postgres sslmode as set via default, config file, or environment variable

func (*ConfigurationData) GetPostgresTransactionTimeout

func (c *ConfigurationData) GetPostgresTransactionTimeout() time.Duration

GetPostgresTransactionTimeout returns the number of minutes to timeout a transaction

func (*ConfigurationData) GetPostgresUser

func (c *ConfigurationData) GetPostgresUser() string

GetPostgresUser returns the postgres user as set via default, config file, or environment variable

func (*ConfigurationData) GetPrivilegeCacheExpirySeconds

func (c *ConfigurationData) GetPrivilegeCacheExpirySeconds() int64

GetPrivilegeCacheExpirySeconds returns the configured number of seconds after which a create privilege cache entry should expire, should it not be marked as stale before this time

func (*ConfigurationData) GetPublicOAuthClientID

func (c *ConfigurationData) GetPublicOAuthClientID() string

GetPublicOAuthClientID returns the public clientID

func (*ConfigurationData) GetRPTTokenMaxPermissions

func (c *ConfigurationData) GetRPTTokenMaxPermissions() int

GetRPTTokenMaxPermissions returns the maximum number of permissions that may be stored in an RPT token

func (*ConfigurationData) GetRefreshTokenExpiresIn

func (c *ConfigurationData) GetRefreshTokenExpiresIn() int64

GetRefreshTokenExpiresIn returns lifespan of user refresh tokens generated by Auth in seconds

func (*ConfigurationData) GetSentryDSN

func (c *ConfigurationData) GetSentryDSN() string

GetSentryDSN returns the secret needed to securely communicate with https://errortracking.prod-preview.openshift.io/openshift_io/fabric8-auth/

func (*ConfigurationData) GetServiceAccountPrivateKey

func (c *ConfigurationData) GetServiceAccountPrivateKey() ([]byte, string)

GetServiceAccountPrivateKey returns the service account private key and its ID that is used to sign service account authentication tokens.

func (*ConfigurationData) GetServiceAccounts

func (c *ConfigurationData) GetServiceAccounts() map[string]ServiceAccount

GetServiceAccounts returns a map of service account configurations by service account ID Default Service Account names and secrets used in Dev mode: "fabric8-wit" : "witsecret" "fabric8-tenant : ["tenantsecretOld", "tenantsecretNew"] "fabric8-jenkins-idler : "secret" "fabric8-jenkins-proxy : "secret" "fabric8-oso-proxy : "secret" "online-registration : "secret" "fabric8-notification : "secret" "rh-che : "secret" "fabric8-gemini-server" : "secret" "toolchain-operator" : "secret"

func (*ConfigurationData) GetTenantServiceURL

func (c *ConfigurationData) GetTenantServiceURL() string

GetTenantServiceURL returns the URL for the Tenant service used by login to initialize OSO tenant space

func (*ConfigurationData) GetTransientTokenExpiresIn

func (c *ConfigurationData) GetTransientTokenExpiresIn() int64

GetTransientTokenExpiresIn returns lifespan of transient (short-lived) access token generated by Auth in seconds

func (*ConfigurationData) GetUserAccountPrivateKey

func (c *ConfigurationData) GetUserAccountPrivateKey() ([]byte, string)

GetUserAccountPrivateKey returns the user account private key and its ID that is used to sign user access and refresh tokens.

func (*ConfigurationData) GetUserDeactivationEnabled

func (c *ConfigurationData) GetUserDeactivationEnabled() bool

GetUserDeactivationEnabled returns true if the user deactivation worker should be enabled

func (*ConfigurationData) GetUserDeactivationFetchLimit

func (c *ConfigurationData) GetUserDeactivationFetchLimit() int

GetUserDeactivationFetchLimit returns the max/limit number of user accounts to deactivate during a worker call

func (*ConfigurationData) GetUserDeactivationInactivityNotificationPeriod

func (c *ConfigurationData) GetUserDeactivationInactivityNotificationPeriod() time.Duration

GetUserDeactivationInactivityNotificationPeriod returns the time duration of inactivity before notifying the user of the imminent account deactivation

func (*ConfigurationData) GetUserDeactivationInactivityPeriod

func (c *ConfigurationData) GetUserDeactivationInactivityPeriod() time.Duration

GetUserDeactivationInactivityPeriod returns the time duration of inactivity before a user account can be deactivated

func (*ConfigurationData) GetUserDeactivationNotificationEnabled

func (c *ConfigurationData) GetUserDeactivationNotificationEnabled() bool

GetUserDeactivationNotificationEnabled returns true if the user deactivation notification worker should be enabled

func (*ConfigurationData) GetUserDeactivationNotificationWorkerInterval

func (c *ConfigurationData) GetUserDeactivationNotificationWorkerInterval() time.Duration

GetUserDeactivationNotificationWorkerInterval returns the interval between 2 cycles of the user deactivation notification worker.

func (*ConfigurationData) GetUserDeactivationRescheduleDelay

func (c *ConfigurationData) GetUserDeactivationRescheduleDelay() time.Duration

GetUserDeactivationRescheduleDelay the delay after which a user is automatically scheduled for another deactivation attempt

func (*ConfigurationData) GetUserDeactivationWhiteList

func (c *ConfigurationData) GetUserDeactivationWhiteList() []string

GetUserDeactivationWhiteList the list of usernames to exclude users from deactivation

func (*ConfigurationData) GetUserDeactivationWorkerInterval

func (c *ConfigurationData) GetUserDeactivationWorkerInterval() time.Duration

GetUserDeactivationWorkerInterval returns the interval between 2 cycles of the user deactivation worker.

func (*ConfigurationData) GetValidRedirectURLs

func (c *ConfigurationData) GetValidRedirectURLs() string

GetValidRedirectURLs returns the RegEx of valid redirect URLs for auth requests If AUTH_REDIRECT_VALID is not set then in Dev Mode all redirects allowed - * Otherwise only *.openshift.io URLs are considered valid

func (*ConfigurationData) GetWITDomainPrefix

func (c *ConfigurationData) GetWITDomainPrefix() string

GetWITDomainPrefix returns the domain prefix which should be used in requests to the auth service

func (*ConfigurationData) GetWITURL

func (c *ConfigurationData) GetWITURL() (string, error)

GetWITURL returns the WIT URL where WIT is running If AUTH_WIT_URL is not set and Auth in not in Dev Mode then we calculate the URL from the Auth Service URL domain

func (*ConfigurationData) IsCleanTestDataEnabled

func (c *ConfigurationData) IsCleanTestDataEnabled() bool

IsCleanTestDataEnabled returns `true` if the test data should be cleaned after each test. (default: true)

func (*ConfigurationData) IsCleanTestDataErrorReportingRequired

func (c *ConfigurationData) IsCleanTestDataErrorReportingRequired() bool

IsCleanTestDataErrorReportingRequired returns `true` if there is any error while cleaning test data after each test. (default: true)

func (*ConfigurationData) IsDBLogsEnabled

func (c *ConfigurationData) IsDBLogsEnabled() bool

IsDBLogsEnabled returns `true` if the DB logs (ie, SQL queries) should be output in the console. (default: false)

func (*ConfigurationData) IsLogJSON

func (c *ConfigurationData) IsLogJSON() bool

IsLogJSON returns if we should log json format (as set via config file or environment variable)

func (*ConfigurationData) IsPostgresDeveloperModeEnabled

func (c *ConfigurationData) IsPostgresDeveloperModeEnabled() bool

IsPostgresDeveloperModeEnabled returns if development related features (as set via default, config file, or environment variable), e.g. token generation endpoint are enabled

func (*ConfigurationData) String

func (c *ConfigurationData) String() string

String returns the current configuration as a string

type ServiceAccount

type ServiceAccount struct {
	Name    string   `mapstructure:"name"`
	ID      string   `mapstructure:"id"`
	Secrets []string `mapstructure:"secrets"`
}

ServiceAccount represents a service account configuration

Jump to

Keyboard shortcuts

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