feat: add JWT authentication for gRPC clients - #1987
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1987 +/- ##
==========================================
+ Coverage 51.71% 52.03% +0.31%
==========================================
Files 100 101 +1
Lines 27222 27986 +764
==========================================
+ Hits 14078 14562 +484
- Misses 13144 13424 +280
🚀 New features to boost your workflow:
|
Signed-off-by: CooooolFrog <zuliangwanghust@gmail.com>
4751184 to
ef1b110
Compare
gaius-qi
left a comment
There was a problem hiding this comment.
We should not build our own token issuance and key rotation. With HS256 the secret must be shared with every verifier, including dfdaemon on every node, so any compromised node can forge
Manager tokens, and we take on key distribution/rotation forever.
Use Kubernetes-issued tokens instead:
Client: projected service account token with our audience (e.g. urn:dragonfly:grpc:manager) + grpc-go's built-in credentials/jwt.NewTokenFileCallCredentials. Rotation is handled by
kubelet.
Server: keep this PR's interceptor and permissive mode, but verify against the cluster JWKS (/openid/v1/jwks) instead of an HMAC keyring.
This gives asymmetric signing, per-workload identity (sub), pod-bound revocation, zero secret management — and deletes roughly half of this PR.
Prior art: Istio (proxies auth to istiod with projected tokens — closest to our case), Teleport (TokenReview or static JWKS for out-of-cluster verifiers), Vault, SPIRE, AWS IRSA. Bare-metal
support can follow Teleport's static-JWKS approach later.
Also: the design doc should go to dragonflyoss/design (kebab-case dir under systems-analysis/), not docs/design/ here.
Description
Add JWT authentication support for inter-component gRPC communication in the Dragonfly Rust Client.
This change introduces:
dragonfly-client-authcrate.dragonflyoss/dragonfly.disabled,permissive, andrequiredmodes.dfctl task preheat.kid-based key rotation.Authentication remains disabled by default. Existing configuration files that do not contain
grpcAuthcontinue to load with the default disabled configuration.Existing public tracing interceptor types remain compatible. JWT authentication is enabled through the new authenticated constructors without changing the existing public client field types.
Validation performed:
cargo check --workspace --all-targets.cargo test --workspace --all-targets.cargo clippy --workspace --all-targets -- -D warnings.cargo fmt --check.Related Issue
Related to dragonflyoss/dragonfly#4417
Motivation and Context
Manager and Scheduler authentication alone is insufficient because dfdaemon, Seed Client, peers, and command-line clients also participate in internal gRPC communication.
This PR implements the Rust side of the shared JWT protocol so Go and Rust components can authenticate each other without introducing a new protobuf API or an external token-issuing service.
The three authentication modes support a simple rolling-upgrade process:
disabledpreserves the existing behavior.permissivesends JWTs while allowing requests from older callers that have not yet been upgraded.requiredenforces authentication after all callers have been upgraded.Old servers ignore the additional authorization metadata sent by upgraded clients. New permissive servers continue to accept old callers without credentials. This allows old and new components to coexist
during the first authenticated rollout.
Screenshots (if appropriate)
N/A
Types of changes
Checklist