|
10 | 10 | from dataclasses import dataclass |
11 | 11 | from typing import Optional |
12 | 12 |
|
13 | | -import requests |
14 | | - |
15 | 13 | from . import oauth |
16 | 14 |
|
17 | 15 | logger = logging.getLogger(__name__) |
@@ -125,31 +123,6 @@ def id_token(self) -> IdToken: |
125 | 123 | return IdToken(jwt=token) |
126 | 124 |
|
127 | 125 |
|
128 | | -class GitHubIdTokenSource(IdTokenSource): |
129 | | - """ |
130 | | - Supplies OIDC tokens from GitHub Actions. |
131 | | - """ |
132 | | - |
133 | | - def __init__(self, request_token: str, request_url: str): |
134 | | - self._request_token = request_token |
135 | | - self._request_url = request_url |
136 | | - |
137 | | - def id_token(self, audience: str) -> IdToken: |
138 | | - # See https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-cloud-providers |
139 | | - headers = {"Authorization": f"Bearer {self._request_token}"} |
140 | | - endpoint = f"{self._request_url}&audience={audience}" |
141 | | - response = requests.get(endpoint, headers=headers) |
142 | | - if not response.ok: |
143 | | - raise ValueError(f"Failed to get ID token: {response.status_code} {response.text}") |
144 | | - |
145 | | - # get the ID Token with aud=api://AzureADTokenExchange sub=repo:org/repo:environment:name |
146 | | - response_json = response.json() |
147 | | - if "value" not in response_json: |
148 | | - raise ValueError("Missing value in response") |
149 | | - |
150 | | - return IdToken(jwt=response_json["value"]) |
151 | | - |
152 | | - |
153 | 126 | class DatabricksOidcTokenSource(oauth.TokenSource): |
154 | 127 | """A TokenSource which exchanges a token using Workload Identity Federation. |
155 | 128 |
|
|
0 commit comments