-
Notifications
You must be signed in to change notification settings - Fork 0
Add to_rsa_format function to normalize private key #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9492523
Add to_rsa_format function to normalize private key
ykitamura-mdsol 0e0c4a3
Update requests_mauth and httpx_mauth to support reading configuratio…
ykitamura-mdsol 7370330
update docs and version
ykitamura-mdsol cc90ef1
Update mauth_client/utils.py
ykitamura-mdsol 0d8cf70
Update mauth_client/utils.py
ykitamura-mdsol f367c0f
Update mauth_client/config.py
ykitamura-mdsol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| import os | ||
| from .utils import to_rsa_format | ||
|
|
||
|
|
||
| class Config: | ||
| APP_UUID = os.environ.get("APP_UUID") | ||
| MAUTH_URL = os.environ.get("MAUTH_URL") | ||
| MAUTH_API_VERSION = os.environ.get("MAUTH_API_VERSION", "v1") | ||
| MAUTH_MODE = os.environ.get("MAUTH_MODE", "local") | ||
| PRIVATE_KEY = os.environ.get("PRIVATE_KEY") | ||
| V2_ONLY_AUTHENTICATE = str(os.environ.get("V2_ONLY_AUTHENTICATE")).lower() == "true" | ||
| SIGN_VERSIONS = os.environ.get("MAUTH_SIGN_VERSIONS", "v1") | ||
| APP_UUID = os.getenv("APP_UUID", os.getenv("MAUTH_APP_UUID")) | ||
| MAUTH_URL = os.getenv("MAUTH_URL") | ||
| MAUTH_API_VERSION = os.getenv("MAUTH_API_VERSION", "v1") | ||
| MAUTH_MODE = os.getenv("MAUTH_MODE", "local") | ||
| _private_key_env = os.getenv("PRIVATE_KEY", os.getenv("MAUTH_PRIVATE_KEY", "")) | ||
| PRIVATE_KEY = to_rsa_format(_private_key_env) if _private_key_env else None | ||
| V2_ONLY_AUTHENTICATE = str(os.getenv("V2_ONLY_AUTHENTICATE")).lower() == "true" | ||
| SIGN_VERSIONS = os.getenv("MAUTH_SIGN_VERSIONS", "v1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import unittest | ||
|
|
||
| from .common import load_key | ||
| from mauth_client.utils import to_rsa_format | ||
|
|
||
| PRIVATE_KEY = load_key("priv").strip() | ||
|
|
||
|
|
||
| class TestToRsaFormat(unittest.TestCase): | ||
| def test_proper_format(self): | ||
| key = to_rsa_format(PRIVATE_KEY) | ||
| self.assertEqual(key, PRIVATE_KEY) | ||
|
|
||
| def test_newlines_replaced_with_spaces(self): | ||
| key_no_newlines = PRIVATE_KEY.replace("\n", " ") | ||
| key = to_rsa_format(key_no_newlines) | ||
| self.assertEqual(key, PRIVATE_KEY) | ||
|
|
||
| def test_newlines_removed(self): | ||
| key_no_newlines = PRIVATE_KEY.replace("\n", "") | ||
| key = to_rsa_format(key_no_newlines) | ||
| self.assertEqual(key, PRIVATE_KEY) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.