Skip to main content

Module console

Module console 

Source
Expand description

HTTP endpoints for the web console.

StructsΒ§

ConsoleProxyConfig πŸ”’

ConstantsΒ§

PREVIEW_BUILD_COOKIE πŸ”’
Cookie storing the selected preview build label.
PREVIEW_BUILD_COOKIE_MAX_AGE_SECS πŸ”’
Preview selections expire after a day so stale cookies drift back to the default build.
PREVIEW_BUILD_LABEL_PREFIX πŸ”’
Prefix required of preview build labels. CI only creates preview aliases under this prefix, so requiring it keeps the reachable hosts to builds of console pull requests.
PREVIEW_BUILD_PARAM πŸ”’
Query parameter that selects (or, with an empty value, clears) the console preview build this proxy serves to the requesting browser.

StaticsΒ§

CONSOLE_CONFIG_VAR_NAMES πŸ”’
OIDC configuration values needed by the Console to initiate OIDC login.

FunctionsΒ§

handle_console_config
Returns system variable values the web console needs from environmentd. This endpoint requires no authentication.
handle_internal_console πŸ”’
The User Impersonation feature uses a Teleport proxy in front of the Internal HTTP Server, however Teleport has issues with CORS that prevent making requests to that Teleport-proxied app from our production console URLs. To avoid CORS and serve the Console from the same host as the Teleport app, this route proxies the upstream Console to handle requests for HTML, JS, and CSS static files.
is_same_origin πŸ”’
True unless the request was initiated by another site. Browser-set Sec-Fetch-Site cannot be forged by page scripts; Origin is the fallback for browsers predating it. The fronting proxy’s SameSite=Lax session cookie also keeps a cross-site POST unauthenticated today, but that is its configuration, not this code’s, so the check here is the layer this proxy owns.
is_valid_preview_build_label πŸ”’
A valid preview build label is a DNS label (1-63 characters of lowercase ASCII alphanumerics and hyphens, not ending with a hyphen) starting with PREVIEW_BUILD_LABEL_PREFIX.
preview_build_confirmation_response πŸ”’
Confirmation page for a preview build selection. All interpolated values are validated or config-controlled, never raw request input.
preview_build_from_cookie πŸ”’
Returns the preview build label from the request’s cookies, if one is set and valid. Invalid values are ignored rather than rejected so a stale cookie can never break the default console.
preview_build_selection_response πŸ”’
Handles the ?preview_build=<label> selection parameter. A GET with a label renders a confirmation page whose form POSTs the selection back; the POST stores it in a cookie and redirects to the same path without the parameter. The POST must additionally be same-origin (see is_same_origin), so a cross-site navigation cannot change the served build even if the fronting proxy’s session cookie policy were to allow cross-site POSTs. Clearing (an empty label) is allowed on GET: it only ever restores the default build and is the recovery path for a broken selection. Returns None when the parameter is absent.
preview_build_unavailable_response πŸ”’
Error page served when the selected preview build cannot be fetched, linking back to the default build.