Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jwt] Fix response for pubilc key server request #2474

Merged
merged 1 commit into from
Aug 26, 2021
Merged

Conversation

wing2fly
Copy link
Collaborator

What changes were proposed in this pull request?

Fix the response from the call to public keys server and loads the json content from response.

How was this patch tested?

Tested in real environment with Hue shell, and fix the unit test.

[root@hue]# build/env/bin/hue shell

(InteractiveConsole)
>>> 
>>> 
>>> import json
>>> import requests
>>> import jwt
>>> from cryptography.hazmat.primitives import serialization
>>> 
>>> headers = {'kid': '1'} 
>>> response = requests.get('http://public_key_server:1234/', headers=headers)
>>> jwk = json.loads(response.content)
>>> public_key = jwt.algorithms.RSAAlgorithm.from_jwk(json.dumps(jwk["keys"][0])).public_key()
>>> public_key_pem = public_key.public_bytes(encoding=serialization.Encoding.PEM, format=serialization.PublicFormat.SubjectPublicKeyInfo)
>>> public_key_pem
'-----BEGIN PUBLIC KEY-----\
.....
-----END PUBLIC KEY-----\n'
>>> 

Please review Hue Contributing Guide before opening a pull request.

@wing2fly wing2fly force-pushed the jwt_validation branch 2 times, most recently from 9c732c7 to c653ebf Compare August 26, 2021 15:27
@wing2fly wing2fly merged commit 061951d into master Aug 26, 2021
@wing2fly wing2fly deleted the jwt_validation branch August 26, 2021 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants