Last active
January 29, 2019 06:51
-
-
Save tylertreat/1dc68e12997e73256c81c74549a9cf6b to your computer and use it in GitHub Desktop.
GCP OIDC proxy URL creation portion of handle_request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_request(proxied_request): | |
"""Proxy the given request to the URL in the Forward-Host header with an | |
Authorization header set using an OIDC bearer token for the Cloud | |
Function's service account. If the header is not present, return a 400 | |
error. | |
""" | |
host = proxied_request.headers.get(HOST_HEADER) | |
if not host: | |
return 'Required header {} not present'.format(HOST_HEADER), 400 | |
scheme = proxied_request.headers.get('X-Forwarded-Proto', 'https') | |
url = '{}://{}{}'.format(scheme, host, proxied_request.path) | |
headers = dict(proxied_request.headers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment