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

Fix api_key encoding/decoding #6608

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

kozlovsky
Copy link
Contributor

This PR fixes #6607 by fixing encoding/decoding of api_key.

@kozlovsky
Copy link
Contributor Author

retest this please

2 similar comments
@kozlovsky
Copy link
Contributor Author

retest this please

@kozlovsky
Copy link
Contributor Author

retest this please

@kozlovsky kozlovsky force-pushed the fix/api_key_encoding branch 4 times, most recently from abc932e to 726e658 Compare December 2, 2021 06:48
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 2, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kozlovsky
Copy link
Contributor Author

retest this please

@kozlovsky kozlovsky marked this pull request as ready for review December 2, 2021 07:06
@kozlovsky kozlovsky requested review from a team and drew2a and removed request for a team December 2, 2021 07:06
@@ -37,7 +37,7 @@ def __init__(self, api_port, api_key, error_handler):
QNetworkAccessManager.__init__(self)
url = QUrl("http://localhost:%d/events" % api_port)
self.request = QNetworkRequest(url)
self.request.setRawHeader(b'X-Api-Key', api_key)
self.request.setRawHeader(b'X-Api-Key', api_key.encode('ascii'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: are you sure that 'ascii' is the correct encoding?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because we construct api_key as hexlify(os.urandom(16)). It contains ASCII symbols only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: setRawHeader argument 2 has unexpected type 'str'
2 participants