Documentation ¶
Index ¶
Constants ¶
const ( // InviteEmailTemplate is the template key for the invite email. InviteEmailTemplate = "INVITE_EMAIL_TEMPLATE" // IndexTemplate is the template key for the index.html. IndexTemplate = "INDEX_HTML_TEMPLATE" )
Variables ¶
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" // NewRelicLicenseEnvVar is the New Relic License key so it can collect data. NewRelicLicenseEnvVar = "CONSOLE_NEW_RELIC_LICENSE" // SecureCookiesEnvVar is set to true or 1, then set the Secure flag be set on session coookies SecureCookiesEnvVar = "SECURE_COOKIES" // LocalCFEnvVar is set to true or 1, then we indicate that we are using a local CF env. LocalCFEnvVar = "LOCAL_CF" // TemplatesPathEnvVar is the path to the templates directory. TemplatesPathEnvVar = "TEMPLATES_PATH" // SMTPHostEnvVar is SMTP host for UAA invites SMTPHostEnvVar = "SMTP_HOST" // SMTPPortEnvVar is SMTP post for UAA invites SMTPPortEnvVar = "SMTP_PORT" // SMTPUserEnvVar is SMTP user for UAA invites SMTPUserEnvVar = "SMTP_USER" // SMTPPassEnvVar is SMTP password for UAA invites SMTPPassEnvVar = "SMTP_PASS" // SMTPFromEnvVar is SMTP from address for UAA invites SMTPFromEnvVar = "SMTP_FROM" // SMTPCertEnvVar is cert for TLS connection SMTPCertEnvVar = "SMTP_CERT" // TICSecretEnvVar is the shared secret with CF API proxy for forwarding client IPs TICSecretEnvVar = "TIC_SECRET" // CSRFKeyEnvVar is used for CSRF token. Must be 32 bytes, hex-encoded, e.g. openssl rand -hex 32 CSRFKeyEnvVar = "CSRF_KEY" // SessionAuthenticationEnvVar used to sign user sessions. Must be 32 or 64 hex-encoded bytes, e.g. openssl rand -hex 64 SessionAuthenticationEnvVar = "SESSION_AUTHENTICATION_KEY" // SessionEncryptionEnvVar used to encrypt user sessions. Must be 16, 24 or 32 hex-encoded bytes, e.g. openssl rand -hex 32 SessionEncryptionEnvVar = "SESSION_ENCRYPTION_KEY" )
var TimeoutConstant = time.Second * 20
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.
Functions ¶
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. Borrowed from https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. Borrowed from https://elithrar.github.io/article/generating-secure-random-numbers-crypto-rand/
func GetValidToken ¶
GetValidToken is a helper function that returns a token struct only if it finds a non expired token for the session.
Types ¶
type Settings ¶
type Settings struct { // OAuthConfig is the OAuth client with all the parameters 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 // Generate secure random state StateGenerator func() (string, error) // UAA API UaaURL string // Log API LogURL string // TemplatesPath is the path to the templates directory. TemplatesPath string // High Privileged OauthConfig HighPrivilegedOauthConfig *clientcredentials.Config // A flag to indicate whether profiling should be included (debug purposes). PProfEnabled bool // Build Info BuildInfo string // Set the secure flag on session cookies SecureCookies bool // Inidicates if targeting a local CF environment. LocalCF bool // URL where this app is hosted AppURL string // SMTP host for UAA invites SMTPHost string // SMTP post for UAA invites SMTPPort string // SMTP user for UAA invites SMTPUser string // SMTP password for UAA invites SMTPPass string // SMTP from address for UAA invites SMTPFrom string // SMTPCert is x509 TLS cert SMTPCert string // Shared secret with CF API proxy TICSecret string // CSRFKey used for gorilla CSRF validation CSRFKey []byte }
Settings is the object to hold global values and objects for the service.
func (*Settings) CreateContext ¶
CreateContext returns a new context to be used for http connections.
type Templates ¶
type Templates struct {
// contains filtered or unexported fields
}
Templates serve as a mapping to various templates. Each entry can be a compilation of multiple files mapped to a string entry. This works if we ever want to use the .define blocks which are good for creating a main template with swappable content. Similar to https://hackernoon.com/golang-template-2-template-composition-and-how-to-organize-template-files-4cb40bcdf8f6
func InitTemplates ¶
InitTemplates will try to parse the templates.