|
23 | 23 | import time
|
24 | 24 | import urllib.parse
|
25 | 25 | import webbrowser
|
26 |
| -from typing import Callable, List, Optional |
27 | 26 |
|
28 | 27 | import requests
|
| 28 | +from id import IdentityError |
29 | 29 | from pydantic import BaseModel, StrictStr
|
30 | 30 |
|
31 | 31 | DEFAULT_OAUTH_ISSUER_URL = "https://oauth2.sigstore.dev/auth"
|
@@ -169,47 +169,3 @@ def identity_token( # nosec: B107
|
169 | 169 | raise IdentityError(f"Error response from token endpoint: {token_error}")
|
170 | 170 |
|
171 | 171 | return str(token_json["access_token"])
|
172 |
| - |
173 |
| - |
174 |
| -class IdentityError(Exception): |
175 |
| - """ |
176 |
| - Raised on any OIDC token format or claim error. |
177 |
| - """ |
178 |
| - |
179 |
| - pass |
180 |
| - |
181 |
| - |
182 |
| -class AmbientCredentialError(IdentityError): |
183 |
| - """ |
184 |
| - Raised when an ambient credential should be present, but |
185 |
| - can't be retrieved (e.g. network failure). |
186 |
| - """ |
187 |
| - |
188 |
| - pass |
189 |
| - |
190 |
| - |
191 |
| -class GitHubOidcPermissionCredentialError(AmbientCredentialError): |
192 |
| - """ |
193 |
| - Raised when the current GitHub Actions environment doesn't have permission |
194 |
| - to retrieve an OIDC token. |
195 |
| - """ |
196 |
| - |
197 |
| - pass |
198 |
| - |
199 |
| - |
200 |
| -def detect_credential() -> Optional[str]: |
201 |
| - """ |
202 |
| - Try each ambient credential detector, returning the first one to succeed |
203 |
| - or `None` if all fail. |
204 |
| -
|
205 |
| - Raises `AmbientCredentialError` if any detector fails internally (i.e. |
206 |
| - detects a credential, but cannot retrieve it). |
207 |
| - """ |
208 |
| - from sigstore._internal.oidc.ambient import detect_gcp, detect_github |
209 |
| - |
210 |
| - detectors: List[Callable[..., Optional[str]]] = [detect_github, detect_gcp] |
211 |
| - for detector in detectors: |
212 |
| - credential = detector() |
213 |
| - if credential is not None: |
214 |
| - return credential |
215 |
| - return None |
0 commit comments