Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 240e98a

Browse files
committed
use urlparse
1 parent 1e3ad74 commit 240e98a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

upload/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import re
33
from json import dumps
44
from typing import Any, Dict, Optional
5+
from urllib.parse import urlparse
56

67
import jwt
78
from asgiref.sync import async_to_sync
@@ -237,16 +238,15 @@ def parse_params(data: Dict[str, Any]) -> Dict[str, Any]:
237238
def get_repo_with_github_actions_oidc_token(token: str) -> Repository:
238239
unverified_contents = jwt.decode(token, options={"verify_signature": False})
239240
token_issuer = str(unverified_contents.get("iss"))
240-
if "https://token.actions.githubusercontent.com" in token_issuer:
241+
parsed_url = urlparse(token_issuer)
242+
if parsed_url.hostname == "token.actions.githubusercontent.com":
241243
service = "github"
242244
jwks_url = "https://token.actions.githubusercontent.com/.well-known/jwks"
243245
else:
244246
service = "github_enterprise"
245247
github_enterprise_url = get_config("github_enterprise", "url")
246248
if not github_enterprise_url:
247-
raise ValidationError(
248-
"GitHub Enterprise URL configuration is not set configuration"
249-
)
249+
raise ValidationError("GitHub Enterprise URL configuration is not set")
250250
# remove trailing slashes if present
251251
github_enterprise_url = re.sub(r"/+$", "", github_enterprise_url)
252252
jwks_url = f"{github_enterprise_url}/_services/token/.well-known/jwks"

0 commit comments

Comments
 (0)