in ad-joining/register-computer/main.py [0:0]
def __authenticate_request(request, require_google_claim=True):
# Only accept requests with an Authorization header.
headerName = "Authorization"
if not headerName in request.headers:
logging.exception("Authentication missing")
flask.abort(HTTP_AUTHENTICATION_REQUIRED, description="CALLER_AUTHENTICATION_MISSING")
# Authenticate the request.
# Expect the host as audience so that multiple deployments of this
# services properly reject tokens issued for other deployments.
try:
return gcp.auth.AuthenticationInfo.from_authorization_header(
request.headers[headerName],
"%s://%s/" % (__get_request_scheme(request), request.host),
require_google_claim)
except gcp.auth.AuthorizationException as e:
logging.exception("Authentication failed")
flask.abort(HTTP_ACCESS_DENIED, description="CALLER_AUTHENTICATION_FAILED")