helpers

package
v0.0.0-...-068e466 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2015 License: CC0-1.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClientIDEnvVar is the environment variable key that represents the registered
	// Client ID for this web app.
	ClientIDEnvVar = "CONSOLE_CLIENT_ID"
	// ClientSecretEnvVar is the environment variable key that represents the
	// Client Secret associated with the registered Client ID for this web app.
	ClientSecretEnvVar = "CONSOLE_CLIENT_SECRET"
	// HostnameEnvVar is the environment variable key that represents the hostname
	// of this web app.
	HostnameEnvVar = "CONSOLE_HOSTNAME"
	// LoginURLEnvVar is the environment variable key that represents the
	// base login URL endpoint that this app should use to authenticate users.
	LoginURLEnvVar = "CONSOLE_LOGIN_URL"
	// UAAURLEnvVar is the environment variable key that represents the
	//  base uaa URL endpoint that this app should use to get tokens.
	UAAURLEnvVar = "CONSOLE_UAA_URL"
	// APIURLEnvVar is the environment variable key that represents the
	// base api URL endpoint that this app should use to access cloud foundry data.
	APIURLEnvVar = "CONSOLE_API_URL"
	// LogURLEnvVar is the environment variable key that represents the
	// endpoint to the loggregator.
	LogURLEnvVar = "CONSOLE_LOG_URL"
	// PProfEnabledEnvVar is the environment variable key that represents if the pprof routes
	// should be enabled. If no value is specified, it is assumed to be false.
	PProfEnabledEnvVar = "PPROF_ENABLED"
	// BuildInfoEnvVar is the environment variable key that represents the particular build number
	BuildInfoEnvVar = "BUILD_INFO"
)
View Source
var TimeoutConstant = time.Second * 5

TimeoutConstant is a constant which holds how long any incoming request should wait until we timeout. This is useful as some calls from the Go backend to the external API may take a long time. If the user decides to refresh or if the client is polling, multiple requests might build up. This timecaps them. This constant is also used in the acceptance testing "delayForRendering" for any pages that may take a long time to render. (Some of those pages use APIs that take a long time)

Functions

func GetValidToken

func GetValidToken(req *http.Request, settings *Settings) *oauth2.Token

GetValidToken is a helper function that returns a token struct only if it finds a non expired token for the session.

Types

type EnvVars

type EnvVars struct {
	ClientID     string
	ClientSecret string
	Hostname     string
	LoginURL     string
	UAAURL       string
	APIURL       string
	LogURL       string
	PProfEnabled string
	BuildInfo    string
}

EnvVars holds all the environment variable values that a non-test server should have.

type Settings

type Settings struct {
	// OAuthConfig is the OAuth client with all the paramters to talk with CF's UAA OAuth Provider.
	OAuthConfig *oauth2.Config
	// Console API
	ConsoleAPI string
	// Login URL - used to redirect users to the logout page
	LoginURL string
	// Sessions is the session store for all connected users.
	Sessions sessions.Store
	// context.Context var from golang.org/x/net/context to make token Client work
	TokenContext context.Context
	// UAA API
	UaaURL string
	// Log API
	LogURL string
	// High Privileged OauthConfig
	HighPrivilegedOauthConfig *clientcredentials.Config
	// A flag to indicate whether profiling should be included (debug purposes).
	PProfEnabled bool
	// Build Info
	BuildInfo string
}

Settings is the object to hold global values and objects for the service.

func (*Settings) InitSettings

func (s *Settings) InitSettings(envVars EnvVars) error

InitSettings attempts to populate all the fields of the Settings struct. It will return an error if it fails, otherwise it returns nil for success.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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