Migrate JWT/JWK auto-refresh from RPCSessions to curl multi singleton#7989
Conversation
Replace rpcsessions->create_client() HTTP fetches in JwtKeyAutoRefresh with ccf::curl::CurlRequest attached to CurlmLibuvContextSingleton, following the pattern established in #7102 for QuoteEndorsementsClient. Changes: - jwt_key_auto_refresh.h: inherit enable_shared_from_this, add send_curl_get() helper with CURLOPT_CAINFO_BLOB CA bundle support, migrate both metadata and JWKS fetches to curl with task-deferred response callbacks - node_state.h: remove rpcsessions parameter from JwtKeyAutoRefresh constructor call - CHANGELOG.md: add [Unreleased] entry for this change Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
The JWT issuer test server creates TLS certs using generate_cert which
hashes the CN (e.g. sha256("localhost")), so libcurl's hostname
verification fails when connecting to the server because neither the CN
nor any SAN matches the actual hostname.
Add an optional `san` parameter to `generate_cert` that, when provided,
adds a DNS Subject Alternative Name extension to the certificate. Update
JwtIssuer._generate_auth_data to pass the hostname as the SAN so that
libcurl can successfully verify the server certificate.
Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
|
@copilot look at the test failures to improve your change. |
…etrics Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Fixed three CI failures in commit
|
Use HTTPS-only curl requests with bounded timeouts for JWT/JWK auto-refresh, and add coverage for connection and TLS refresh failures. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Normalize the parsed jwks_uri scheme before enforcing HTTPS-only refreshes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5ce8852
into
copilot/jwk-refresh-curl-multi-plan
Migrates JWT/JWK auto-refresh outbound HTTP fetches away from the legacy
RPCSessions::create_client()path and ontoccf::curl::CurlRequestattached toCurlmLibuvContextSingleton, following the curl multi singleton direction introduced in #7102.Core changes
src/node/jwt_key_auto_refresh.hRPCSessionsdependency fromJwtKeyAutoRefresh.jwt.key_refresh_max_response_sizenode startup config setting (default 1 MB).send_refresh_jwt_keys_error(), so refresh failure metrics include network-level fetch failures.src/node/node_state.hJwtKeyAutoRefreshwithout passingrpcsessions.jwt.key_refresh_max_response_sizevalue into auto-refresh.src/http/curl.hcurl_easy_getinfoandcurl_multi_get_handlesresults in curl cleanup paths.curl_slist_appendfailures without leaking the existing list.Metadata and JWKS behavior
issuerconstraints inside the metadata parse error path, so malformed/non-string values are recorded as refresh failures rather than escaping the task.SetJwtPublicSigningKeysrequest.jwks_uribefore handing it to curl:jwks_urihost/port to differ from the issuer authority. OIDC Discovery requires HTTPS forjwks_uri, but does not require matching issuer/JWKS authorities; Google is a common provider where these authorities differ.Configuration and docs
jwt.key_refresh_max_response_sizeto startup config, JSON config handling, config schema, generated operations docs, test infra config generation, and JWT app docs.7.0.7and updatespython/pyproject.tomlto7.0.7.Tests
Adds/updates JWT auto-refresh coverage for:
jwks_urisucceeding.Validation run locally
ninja -C build logging curl_testcd build && ../tests/.venv/bin/python ../tests/e2e_curl.pyjwt_test.run_manual(args)against rebuiltbuild/samples/apps/logging/logging