OXIESEC PANEL
- Current Dir:
/
/
opt
/
gsutil
/
third_party
/
google-auth-library-python
/
google
/
auth
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
11/30/2023 05:43:15 PM
rwxr-xr-x
📄
__init__.py
1.95 KB
11/30/2023 05:43:15 PM
rw-r--r--
📁
__pycache__
-
02/11/2025 08:19:49 AM
rwxr-xr-x
📄
_cloud_sdk.py
5.09 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_credentials_async.py
6.64 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_default.py
27.87 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_default_async.py
11.3 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_exponential_backoff.py
3.81 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_helpers.py
8.04 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_jwt_async.py
5.83 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_oauth2client.py
5.72 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
_service_account_info.py
2.75 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
api_key.py
2.52 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
app_engine.py
5.98 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
aws.py
29.77 KB
11/30/2023 05:43:15 PM
rw-r--r--
📁
compute_engine
-
11/30/2023 05:43:15 PM
rwxr-xr-x
📄
credentials.py
15.27 KB
11/30/2023 05:43:15 PM
rw-r--r--
📁
crypt
-
02/11/2025 08:19:49 AM
rwxr-xr-x
📄
downscoped.py
20.96 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
environment_vars.py
3.22 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
exceptions.py
2.89 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
external_account.py
21.67 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
external_account_authorized_user.py
12.56 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
iam.py
3.57 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
identity_pool.py
10.42 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
impersonated_credentials.py
16.44 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
jwt.py
30.37 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
metrics.py
5.48 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
pluggable.py
16.9 KB
11/30/2023 05:43:15 PM
rw-r--r--
📄
py.typed
74 bytes
11/30/2023 05:43:15 PM
rw-r--r--
📁
transport
-
02/11/2025 08:19:48 AM
rwxr-xr-x
📄
version.py
598 bytes
11/30/2023 05:43:15 PM
rw-r--r--
Editing: metrics.py
Close
# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ We use x-goog-api-client header to report metrics. This module provides the constants and helper methods to construct x-goog-api-client header. """ import platform from google.auth import version API_CLIENT_HEADER = "x-goog-api-client" # BYOID Specific consts BYOID_HEADER_SECTION = "google-byoid-sdk" # Auth request type REQUEST_TYPE_ACCESS_TOKEN = "auth-request-type/at" REQUEST_TYPE_ID_TOKEN = "auth-request-type/it" REQUEST_TYPE_MDS_PING = "auth-request-type/mds" REQUEST_TYPE_REAUTH_START = "auth-request-type/re-start" REQUEST_TYPE_REAUTH_CONTINUE = "auth-request-type/re-cont" # Credential type CRED_TYPE_USER = "cred-type/u" CRED_TYPE_SA_ASSERTION = "cred-type/sa" CRED_TYPE_SA_JWT = "cred-type/jwt" CRED_TYPE_SA_MDS = "cred-type/mds" CRED_TYPE_SA_IMPERSONATE = "cred-type/imp" # Versions def python_and_auth_lib_version(): return "gl-python/{} auth/{}".format(platform.python_version(), version.__version__) # Token request metric header values # x-goog-api-client header value for access token request via metadata server. # Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/mds" def token_request_access_token_mds(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ACCESS_TOKEN, CRED_TYPE_SA_MDS ) # x-goog-api-client header value for ID token request via metadata server. # Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/mds" def token_request_id_token_mds(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_MDS ) # x-goog-api-client header value for impersonated credentials access token request. # Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/imp" def token_request_access_token_impersonate(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ACCESS_TOKEN, CRED_TYPE_SA_IMPERSONATE, ) # x-goog-api-client header value for impersonated credentials ID token request. # Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/imp" def token_request_id_token_impersonate(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_IMPERSONATE ) # x-goog-api-client header value for service account credentials access token # request (assertion flow). # Example: "gl-python/3.7 auth/1.1 auth-request-type/at cred-type/sa" def token_request_access_token_sa_assertion(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ACCESS_TOKEN, CRED_TYPE_SA_ASSERTION ) # x-goog-api-client header value for service account credentials ID token # request (assertion flow). # Example: "gl-python/3.7 auth/1.1 auth-request-type/it cred-type/sa" def token_request_id_token_sa_assertion(): return "{} {} {}".format( python_and_auth_lib_version(), REQUEST_TYPE_ID_TOKEN, CRED_TYPE_SA_ASSERTION ) # x-goog-api-client header value for user credentials token request. # Example: "gl-python/3.7 auth/1.1 cred-type/u" def token_request_user(): return "{} {}".format(python_and_auth_lib_version(), CRED_TYPE_USER) # Miscellenous metrics # x-goog-api-client header value for metadata server ping. # Example: "gl-python/3.7 auth/1.1 auth-request-type/mds" def mds_ping(): return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_MDS_PING) # x-goog-api-client header value for reauth start endpoint calls. # Example: "gl-python/3.7 auth/1.1 auth-request-type/re-start" def reauth_start(): return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_REAUTH_START) # x-goog-api-client header value for reauth continue endpoint calls. # Example: "gl-python/3.7 auth/1.1 cred-type/re-cont" def reauth_continue(): return "{} {}".format(python_and_auth_lib_version(), REQUEST_TYPE_REAUTH_CONTINUE) # x-goog-api-client header value for BYOID calls to the Security Token Service exchange token endpoint. # Example: "gl-python/3.7 auth/1.1 google-byoid-sdk source/aws sa-impersonation/true sa-impersonation/true" def byoid_metrics_header(metrics_options): header = "{} {}".format(python_and_auth_lib_version(), BYOID_HEADER_SECTION) for key, value in metrics_options.items(): header = "{} {}/{}".format(header, key, value) return header def add_metric_header(headers, metric_header_value): """Add x-goog-api-client header with the given value. Args: headers (Mapping[str, str]): The headers to which we will add the metric header. metric_header_value (Optional[str]): If value is None, do nothing; if headers already has a x-goog-api-client header, append the value to the existing header; otherwise add a new x-goog-api-client header with the given value. """ if not metric_header_value: return if API_CLIENT_HEADER not in headers: headers[API_CLIENT_HEADER] = metric_header_value else: headers[API_CLIENT_HEADER] += " " + metric_header_value