Data plane signaling (OAuth2 token exchange): a token exchange and a JWKS fetch on every signaling request

Aperta
#6,178 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
java

Direzione di ricerca

Start in data-plane-signaling-oauth2-token-exchange, especially Oauth2TokenExchangeSignalingAuthorization.evaluate and isAuthorized, then read Oauth2ClientImpl and JwksPublicKeyResolver for token expiry and resolver caching behavior. Implement bounded token reuse keyed by exchange parameters and subject token, plus reuse of JWKS resolvers with configurable validity. Done means repeated requests reuse valid cached credentials and keys, expired or changed credentials refresh appropriately, and the cache setting can preserve per-request exchanges.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature_request triage

Feature Request

Cache what the oauth2_token_exchange signaling authorization obtains over the network:

  • the exchanged token, on the sending side;
  • the counter-party's JWKS, on the receiving side.

Which Areas Would Be Affected?

data-plane-signaling-oauth2-token-exchange: Oauth2TokenExchangeSignalingAuthorization.

Why Is the Feature Desired?

Sending side (evaluate). Every signaling call from the controlplane to a data plane (prepare, start, suspend,
terminate) first exchanges the workload credential for a token at the token exchange endpoint. That is a synchronous
HTTP round trip on the state machine worker, before the signaling call itself. The Javadoc says this is deliberate:
"Exchanged tokens are not cached: every signaling request triggers a fresh exchange". As a result:

  • every signaling step costs two round trips instead of one;
  • the token exchange service gets the same request rate as the data plane;
  • a worker of the transfer state machine waits for both calls. With the NATS task-based state machines, throughput is roughly workers ÷ step round trip, so the extra round trip lowers the ceiling directly.

In a load test (single runtime hosting provider and consumers, 40 negotiation+transfer flows/s, 16 transfer workers), a thread dump showed 7 of the 16 transfer workers inside Oauth2ClientImpl.requestToken, called from Oauth2TokenExchangeSignalingAuthorization.obtainToken, for prepare, start and terminate.

Receiving side (isAuthorized). For every incoming signaling request (data plane → controlplane callbacks), the
authorization builds a new JwksPublicKeyResolver with JwksPublicKeyResolver.create(keyParserRegistry, jwksUri, monitor), the factory without a cache. So every callback fetches the JWKS over HTTP before the token can be verified.

Solution Proposal

  1. Cache exchanged tokens in evaluate.
    • Key: the exchange parameters (tokenExchangeEndpoint, resource, audience, scope) plus the subject token (or its hash), so that a rotated workload credential (e.g. a projected ServiceAccount token) results in a new exchange.
    • Lifetime: the token's expires_in, which Oauth2ClientImpl already parses into
      TokenRepresentation.expiresIn, minus a safety margin (e.g. 10–30 s or a fraction of the lifetime). Tokens without expires_in are not cached, which is the current behavior.
    • Bounded size (LRU), since the key includes per-data-plane values.
    • Opt-in or opt-out setting: e.g. edc.signaling.oauth2.tokenexchange.cache.enabled, for deployments that want one token per request.
  2. Reuse the JWKS resolver in isAuthorized: keep one JwksPublicKeyResolver per jwksUri, created with
    create(keyParserRegistry, jwksUrl, monitor, cacheValidityMs), so that keys are cached and refreshed through the Nimbus JWKSource (rate limiting, refresh-ahead). Make the validity configurable, as other JWKS consumers in EDC do.
Lingua principale
Java
Stelle
429
Fork
302
Merge medio
10h 46m
PR unite (30g)
75

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di eclipse-edc/Connector

Tutte le issue di eclipse-edc/Connector

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.