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

Sort Signing Keys on Marshal #203

Merged
merged 1 commit into from
Aug 21, 2023
Merged

Sort Signing Keys on Marshal #203

merged 1 commit into from
Aug 21, 2023

Conversation

sethjback
Copy link
Contributor

Sort the signing keys by their public nkey during the json marshaling process to ensure the generated json array is always the same.

Since ranging over a map in golang is intentionally random, prior behavior would generate a random order for the signing key output. Arrays in json are considered ordered, so this would cause test that compare the json generated from the same SigningKeys to occasionally fail: ["sk1","sk2"] != ["sk2","sk1"]

@sethjback sethjback requested a review from aricart August 21, 2023 19:46
@coveralls
Copy link

Pull Request Test Coverage Report for Build 5930771495

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 80.957%

Totals Coverage Status
Change from base Build 5928958397: 0.02%
Covered Lines: 2691
Relevant Lines: 3324

💛 - Coveralls

@aricart
Copy link
Member

aricart commented Aug 21, 2023

Note that JWTs are not only generated by the go library, so this behaviour is not going to hold for anything that comes from the outside. I would instead guarantee the ordering you want as application logic on decoding. With that said, I like the presentation to be ordered as well.

Copy link
Member

@aricart aricart left a comment

Choose a reason for hiding this comment

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

LGTM

@aricart aricart merged commit 44fe206 into main Aug 21, 2023
4 checks passed
@aricart aricart deleted the sk_sort branch August 21, 2023 20:24
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.

3 participants