-
-
Notifications
You must be signed in to change notification settings - Fork 12
pick_random_key algorithm parameter is optional
#83
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR makes the algorithm parameter optional in the pick_random_key method by adding a default value of None. When no algorithm is specified, the method falls back to selecting randomly from all keys in the set.
- Added default value
Noneto thealgorithmparameter inpick_random_keymethod signature - Added a unit test to verify the method works correctly when called without arguments
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/joserfc/_keys.py | Updated pick_random_key method signature to make algorithm parameter optional with default value None |
| tests/jwk/test_jwk_set.py | Added test case to verify pick_random_key() can be called without arguments and returns a key |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eca88af to
ee046b2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #83 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 2850 2850
Branches 320 320
=========================================
Hits 2850 2850
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
The method is used in return_key = resolved_key.pick_random_key(headers["alg"], parameters)skey = key.pick_random_key(headers["alg"])When this method is used, the algorithm name is always known. |
|
I was thinking of other use cases. For example, in an OIDC server, if a client has not been set a favorite alg for signing, one might want to just use a random key among the keys available, and call |
Actually that was already available, but this adds a default value and a unit test.