Skip to content

Commit

Permalink
Pass in headers instead of modifying global opener
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin5605 committed Mar 13, 2024
1 parent f839ac6 commit 8c49e48
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/mainframe/json_web_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
UnableCredentialsException,
)

from urllib.request import build_opener, install_opener

opener = build_opener()
opener.addheaders = [('User-Agent','Dragonfly Mainframe')]
install_opener(opener)

@dataclass
class AuthenticationData:
issuer: str
Expand Down Expand Up @@ -44,7 +38,7 @@ class JsonWebToken:

def validate(self) -> AuthenticationData:
try:
jwks_client = jwt.PyJWKClient(keycloak_settings.jwks_uri)
jwks_client = jwt.PyJWKClient(keycloak_settings.jwks_uri, headers={"User-Agent": "Dragonfly Mainframe"})
jwt_signing_key = jwks_client.get_signing_key_from_jwt(self.jwt_access_token).key
payload = jwt.decode(
self.jwt_access_token,
Expand Down

0 comments on commit 8c49e48

Please sign in to comment.