Repository navigation
Conversation
|
Thank you for your contribution. Since you are not yet a member of the Ceph organization with write permissions on ceph/ceph.git, our CI will not automatically run. Any member of the Ceph organization may label this PR |
698ed9c to
4a2a732
Compare
|
This has been attempted in the past and has introduced regressions in the tags parsing code in AssumeRoleWithWebIdentity |
@pritha-srivastava I believe this is the regression you're referencing: #61796 (comment). I'll take some time to assess what it would take to cover the regression. Thank you so much for the context! |
4a2a732 to
1b1faae
Compare
|
@ta1hia : give me a couple of days, I will review this PR |
| jwt::json::type c_type = c.get_type(); | ||
|
|
||
| // Ignore root placeholder or namespace keys if passed on non-container types | ||
| if ((key == "dummy" || key == "https://aws.amazon.com/tags") && |
There was a problem hiding this comment.
what if the claim name is actually "dummy"
There was a problem hiding this comment.
this check was there to catch the placeholder key passed from get_from_jwt when starting recursion on principal tags, but you're right that an actually "dummy" claim would get silently ignored here
instead of overloading the key name, i can add a bool is_root_tags param to recurse_and_insert and check that instead to be explicit
| } | ||
|
|
||
| std::string | ||
| WebTokenEngine::get_pem_from_jwk(const std::string& n_b64url, const std::string& e_b64url) const |
There was a problem hiding this comment.
I believe jwt::helper::create_public_key_from_rsa_components(n, e) can be used to convert n& e JWK to PEM
| b64_iter(sview.data() + sview.size())); | ||
|
|
||
| return outstr; | ||
| try { |
There was a problem hiding this comment.
avoid decoder changes here and let the error be visible to the callers so that they decide what to do with the error
|
@cbodley : this is a PR that aims to replace jwt-cpp from our code with the updated submodule. Earlier this attempt had introduced regressions in principal tags parsing in PR #61796 (comment) and hence the submodule was dropped. But this PR attempts to overcome the regression. I have already reviewed the PR. Request you to also take a look. Once the PR is approved and passes qa (to confirm there's no regression), we would need someone in the community to help test web keys with n&e as Keycloak does not provide web keys with n&e (atleast it didn't till I looked into it last) |
f621c96 to
69010a6
Compare
| continue; | ||
| } | ||
| // Drop wrapper keys for child containers; preserve valid keys for array items | ||
| std::string next_key = (is_root_tags || key == princTagsNamespace) ? "" : key; |
There was a problem hiding this comment.
consider JWT that has the following structure:
{
"custom": {
"https://aws.amazon.com/tags": ["engineering"],
"": ["enabled"]
}
}
where someone has decided to use "https://aws.amazon.com/tags" and "" as keys.
The code here causes it to drop real data, including scalar values under a nested field named https://aws.amazon.com/tags and array values under a valid empty key "". The new is_root_tags flag fixes the "dummy" collision, but those two cases remain.
You can keep the AWS namespace check at the top-level lookup and give the recurse_and_insert method a std::optionalstd::string_view key. Pass std::nullopt at the unnamed tags root (e.g for custom). Objects supply each member’s real key, arrays pass the current key through, and scalars are emitted whenever a key is present, even if it’s "". Keep skipping JSON null
There was a problem hiding this comment.
i simplified recurse_and_insert with your suggestions to fix the two data loss edge cases + added some additional test cases to verify the behaviour. thank you for catching this again!
@pritha-srivastava i don't understand the contents of these json documents well enough to review in detail, so i would rely on test coverage to validate. my recollection is that nesting didn't work in the earlier attempt, and i see that there are unit tests for that here if we don't have access to a non-keycloak server to test against, could we at least get a sample json document that we build a unit test for? |
I'll see if we can build a sample JSON for n&e testing. The unit tests here cover various kinds of nested and flattened JSON samples including the one that caused regression last time. Can you please review the submodule part as I am not very well versed with that. |
|
ok I generated a sample JWT using codex: and its corresponding JWKS: and verified the JWT and its signature on https://www.jwt.io/ |
There was a problem hiding this comment.
submodule changes look good 👍 the submodule points to the v0.7.2 release. i see that 0.7.3 was just tagged yesterday. it might be worth seeing whether that includes any changes that are relevant here
otherwise just minor comments on cmake bits
65969e0 to
99c7ac5
Compare
|
thank you both for taking a look! i’ve updated the PR with the following- @pritha-srivastava: i updated @cbodley: i removed the redundant statements in cmake and bumped jwt-cpp to v0.7.3 by the way, is it preferable if i squash my commits into a single commit right now, or is that done at the time of merging? |
|
the code looks good to me. you can separate out the commits into two - 1. code changes 2. unit tests and add an assisted-by line in the commit before Signed-off by according to open source coding guidelines like the following (we used it to generate the token): @cbodley : do the cmake changes look fine? |
Replaces the vendored jwt-cpp headers with a git submodule pinned to the upstream v0.7.3 release. Update the STS web token engine for the new jwt-cpp API and extract principal tags in get_principal_tags(). Change recurse_and_insert() to take std::optional<std::string_view> and check the AWS tags namespace only at the top level so nested keys matching the namespace and empty keys are preserved. Fixes: https://tracker.ceph.com/issues/70910 Signed-off-by: Tahia Khan <[email protected]>
Adds unittest_rgw_web_token, covering claim flattening in recurse_and_insert(), get_token_claims() and get_principal_tags(), and RS256 signature validation from JWKS n/e components. Fixes failing BADINPUT tests in test_rgw_token. Fixes: https://tracker.ceph.com/issues/70910 Assisted-by: Codex GPT 6.2 Sol Signed-off-by: Tahia Khan <[email protected]>
99c7ac5 to
eace527
Compare
Fixes: sts: replace src/rgw/jwt-cpp/ with submodule
The vendored jwt-cpp headers had local additions like
setModulusExponentCalcPublicKeyand manual BIGNUM/RSA helpers that aren't in any upstream releases. Because of that, swapping to upstreamv0.7.2as a submodule wasn't a clean drop-in file swap and needed some extra effort to adapt to API/template changes:expectmacro collision in rgw_rest_sts.h with#pragma push_macro/#pop_macro.jwt::helper::create_public_key_from_rsa_componentsfor RSA JWK components, and refactoredrecurse_and_insert()(skipping null values and dropping thedummysentinel in favor ofis_root_tagsandprincTagsNamespace) alongside splitting principal tag extraction intoget_principal_tags().WebTokenEngineTestAccesshooks and unit tests intest_rgw_web_token.cccovering the refactored behavior.Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.