This repository was archived by the owner on Jun 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
codecov_auth/authentication Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 99from django .utils import timezone
1010from jwt import PyJWTError
1111from rest_framework import authentication , exceptions , serializers
12- from rest_framework .exceptions import NotAuthenticated
12+ from rest_framework .exceptions import NotAuthenticated , ValidationError
1313from rest_framework .response import Response
1414from rest_framework .views import exception_handler
1515from shared .django_apps .codecov_auth .models import Owner
@@ -200,7 +200,7 @@ def authenticate(
200200 if not using_global_token :
201201 return None # continue to next auth class
202202
203- service = global_tokens [ token ]
203+ service = global_tokens . get ( token , "" )
204204 upload_info = get_upload_info_from_request_path (request )
205205 if upload_info is None :
206206 return None # continue to next auth class
@@ -257,7 +257,7 @@ def authenticate_credentials(
257257
258258 try :
259259 repository = get_repo_with_github_actions_oidc_token (token )
260- except (ObjectDoesNotExist , PyJWTError ):
260+ except (ObjectDoesNotExist , PyJWTError , ValidationError ):
261261 return None # continue to next auth class
262262
263263 log .info (
Original file line number Diff line number Diff line change @@ -243,6 +243,10 @@ def get_repo_with_github_actions_oidc_token(token: str) -> Repository:
243243 else :
244244 service = "github_enterprise"
245245 github_enterprise_url = get_config ("github_enterprise" , "url" )
246+ if not github_enterprise_url :
247+ raise ValidationError (
248+ "GitHub Enterprise URL configuration is not set configuration"
249+ )
246250 # remove trailing slashes if present
247251 github_enterprise_url = re .sub (r"/+$" , "" , github_enterprise_url )
248252 jwks_url = f"{ github_enterprise_url } /_services/token/.well-known/jwks"
@@ -525,7 +529,7 @@ def insert_commit(
525529 return commit
526530
527531
528- def get_global_tokens () -> Dict [str , Any ]:
532+ def get_global_tokens () -> Dict [str | None , Any ]:
529533 """
530534 Enterprise only: check the config to see if global tokens were set for this organization's uploads.
531535
You can’t perform that action at this time.
0 commit comments