Skip to content

CMR-11629: As a CMR operator I want the CMR to validate EDL JWTs with EDL when local verification is off - #2538

Merged
daniel-zamora merged 7 commits into
masterfrom
CMR-11629
Nov 17, 2026
Merged

daniel-zamora merged 7 commits into
masterfrom
CMR-11629

Conversation

@daniel-zamora

@daniel-zamora daniel-zamora commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Overview

What is the objective?

With CMR_LOCAL_EDL_VERIFICATION false, CMR sent EDL JWTs to the retired ECHO REST token endpoint, so every JWT was rejected. With it true, CMR only checks a JWT's signature and expiry, so a token revoked in EDL keeps working until it expires. This validates JWTs with EDL when local verification is off, and on all writes.

What are the changes?

  • With local verification off, tokens/get-user-id validates JWTs with EDL token introspection (POST /oauth/introspect, Basic auth with CMR's EDL app credentials) instead of the legacy call.
  • Writes always validate JWTs with EDL, whatever CMR_LOCAL_EDL_VERIFICATION is set to: ingest (concepts, generic documents, bulk updates, subscriptions, providers), access-control (groups, ACLs) and search (tags, associations, humanizers, community usage metrics). Admin maintenance routes are not covered. With local verification on, the local signature and expiry check still runs first.
  • CMR_LOCAL_EDL_VERIFICATION now only decides reads. With it true, reads are unchanged; writes with a JWT need EDL to be reachable.
  • New CMR_EDL_VALIDATE_WRITE_TOKENS, default true. False turns the write check off, so writes verify JWTs the same way as reads.
  • The user comes from the introspection response's uid, username or sub, and the token must be active.
  • Results are cached per token in the Launchpad user cache for CMR_EDL_TOKEN_CACHE_SECONDS (default 300), or until the token expires if sooner. Rejections are cached the same way as for Launchpad tokens.
  • The cache lookup is now shared by Launchpad and EDL tokens. The EDL call happens outside the cache update, and a failed revalidation of an expired entry is not cached.
  • EDL being unreachable or answering unexpectedly returns 528, rejected app credentials 500, rate limiting 429. Introspection calls time out after 5 seconds to connect and 10 seconds to read.
  • is-jwt-token? trims the token and matches all of it instead of searching within it.
  • The legacy ECHO REST request log line no longer logs the Authorization header or connection settings, and scrubs the token.

What areas of the application does this impact?

  • transmit-lib
  • common-lib
  • common-app-lib
  • ingest-app
  • search-app
  • access-control-app (through the shared write token check)

Required Checklist

  • New and existing unit and int tests pass locally and remotely
  • clj-kondo has been run locally and all errors in changed files are corrected
  • I have commented my code, particularly in hard-to-understand areas
  • I have made changes to the documentation (if necessary)
  • My changes generate no new warnings

Additional Checklist

  • I have removed unnecessary/dead code and imports in files I have changed
  • I have cleaned up integration tests by doing one or more of the following:
    • migrated any are2 tests to are3 in files I have changed
    • de-duped, consolidated, removed dead int tests
    • transformed applicable int tests into unit tests
    • reduced number of system state resets by updating fixtures. Ex) (use-fixtures :each (ingest/reset-fixture {})) to be :once instead of :each

@daniel-zamora daniel-zamora changed the title Cmr 11629 CMR-11629: As a CMR operator I want the CMR to validate EDL JWTs with EDL when local verification is off Nov 14, 2026

@jceaser jceaser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

consider adding a commend and using a random text generator.

[cmr.transmit.tokens :as tokens]))

(deftest loggable-params-test
(let [system-token "system-token-0123456789-abcdefghij"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

don't we have a random text generator for using in tests instead of having a hard coded token?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it probably wouldn't hurt but this is more deterministic.

@codecov-commenter

codecov-commenter commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 64.08451% with 51 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.51%. Comparing base (b84609f) to head (fa62e53).

Files with missing lines Patch % Lines
...smit-lib/src/cmr/transmit/launchpad_user_cache.clj 67.34% 13 Missing and 3 partials ⚠️
transmit-lib/src/cmr/transmit/tokens.clj 36.84% 10 Missing and 2 partials ⚠️
search-app/src/cmr/search/api/tags.clj 0.00% 7 Missing ⚠️
ingest-app/src/cmr/ingest/api/provider.clj 0.00% 3 Missing ⚠️
transmit-lib/src/cmr/transmit/urs.clj 92.50% 3 Missing ⚠️
ingest-app/src/cmr/ingest/api/subscriptions.clj 0.00% 2 Missing ⚠️
search-app/src/cmr/search/api/association.clj 0.00% 2 Missing ⚠️
...rch-app/src/cmr/search/api/generic_association.clj 0.00% 2 Missing ⚠️
.../cmr/common_app/api/launchpad_token_validation.clj 90.90% 0 Missing and 1 partial ⚠️
...app/src/cmr/search/api/community_usage_metrics.clj 0.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2538      +/-   ##
==========================================
+ Coverage   54.46%   54.51%   +0.05%     
==========================================
  Files        1047     1047              
  Lines       73552    73638      +86     
  Branches     2413     2418       +5     
==========================================
+ Hits        40057    40147      +90     
+ Misses      31220    31205      -15     
- Partials     2275     2286      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@daniel-zamora
daniel-zamora merged commit b7208d8 into master Nov 17, 2026
6 checks passed
isja17 pushed a commit that referenced this pull request Nov 17, 2026
… EDL when local verification is off (#2538)

* CMR-11629: validate EDL JWTs with EDL when local verification is off

* CMR-11629: validate EDL JWTs with token introspection

* CMR-11629: read the user from EDL introspection username

* CMR-11629: always validate JWTs with EDL on writes

* CMR-11629: report EDL credential failures as server errors and skip the system token

* CMR-11629: check search and provider writes with EDL, add an emergency switch and anchor JWT detection

* CMR-11629: note the test token is a sample
isja17 pushed a commit that referenced this pull request Nov 17, 2026
… EDL when local verification is off (#2538)

* CMR-11629: validate EDL JWTs with EDL when local verification is off

* CMR-11629: validate EDL JWTs with token introspection

* CMR-11629: read the user from EDL introspection username

* CMR-11629: always validate JWTs with EDL on writes

* CMR-11629: report EDL credential failures as server errors and skip the system token

* CMR-11629: check search and provider writes with EDL, add an emergency switch and anchor JWT detection

* CMR-11629: note the test token is a sample
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.

4 participants