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

FI-3155 Fix JWT encoding method #5

Merged
merged 4 commits into from
Sep 27, 2024
Merged

Conversation

alisawallace
Copy link
Collaborator

Summary

This PR updates the test kit to use the Base64.encode64/decode64 methods for the X.509 certs in the JWTs, instead of the original Base64.urlsafe_encode64/decode64 methods that resulted in JWTs whose signature could not be verified, causing tests to always fail.

Testing Guidance

I originally discovered and fixed the bug using the presets in the following branch: https://github.com/inferno-framework/udap-security-test-kit/tree/udaped-partial-demo

However, any valid registration inputs (including Inferno's test certs) can be used to run the Dynamic Client Registration test group and demonstrate the issue.
The software statement JWT can be grabbed from the HTTP request or the test output for test 1.2.03 registration success and pasted into jwt.io. Before changing the encode method, it will say "Signature verification failed", but after the signature verification will succeed. Also, if using the partial demo presets, the test itself should "fail" with a 200 response code instead of a 400 saying "Missing validation result."

@alisawallace
Copy link
Collaborator Author

I ran bundle update before making these changes, and as a result two spec tests for generate_client_certs, unrelated to the JWT encoding change, are now failing due to what I believe are changes in how core handles null inputs. I'm not sure how to resolve this, @Jammjammjamm could you advise?

@Jammjammjamm
Copy link
Contributor

The test isn't required anywhere in the actual test kit, so it isn't loaded into the test repository. So the spec is currently testing dead code, which is a bit odd. If this test and spec are worth keeping, you can change the definition of runnable to just be described_class rather than finding it through the repository.

@alisawallace
Copy link
Collaborator Author

The test isn't required anywhere in the actual test kit, so it isn't loaded into the test repository. So the spec is currently testing dead code, which is a bit odd. If this test and spec are worth keeping, you can change the definition of runnable to just be described_class rather than finding it through the repository.

I see now, the generate_client_certs_test is less dead and more temporarily asleep, since this is a feature we plan to add back in the future once our certs are up to snuff (I believe we have a ticket for it), but took out in the meantime for release. To keep it simple I just added this as a requirement to the dynamic client registration group where it was used and will be used in the future, and that fixed the tests without needing to redefine runnable.

@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
spec.description = 'UDAP Security IG Test Kit'
spec.homepage = 'https://github.com/inferno-framework/udap-security-test-kit'
spec.license = 'Apache-2.0'
spec.add_runtime_dependency 'inferno_core', '>= 0.4.2'
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops!

Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, why is this changing? I see spec.add_runtime_dependency everywhere else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this was a Rubocop auto-correction. When I revert it back to the original my editor gives me a blue squiggly line and says:

Gemspec/AddRuntimeDependency: Use add_dependency instead of add_runtime_dependency.RuboCopGemspec/AddRuntimeDependency

I saw you approved the PR but from this comment can't tell if you changed your mind, so @Jammjammjamm just confirm if I'm good to go or if you want me to revert to spec.add_runtime_dependency!

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, it's good to go.

@Jammjammjamm Jammjammjamm merged commit 8fd16bc into main Sep 27, 2024
3 checks passed
@Jammjammjamm Jammjammjamm deleted the FI-3155-jwt-encode-fix branch September 27, 2024 13:15
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.

2 participants