feat: secure internal gRPC with JWT - #4938
Open
CooooolFrog wants to merge 1 commit into
Open
Conversation
CooooolFrog
requested review from
BraveY,
BruceAko,
ClementMaH,
gaius-qi,
hyy0322 and
xujihui1985
August 13, 2026 08:39
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4938 +/- ##
==========================================
+ Coverage 28.86% 29.77% +0.91%
==========================================
Files 226 229 +3
Lines 22565 22858 +293
==========================================
+ Hits 6513 6807 +294
+ Misses 15605 15583 -22
- Partials 447 468 +21
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Signed-off-by: CooooolFrog <zuliangwanghust@gmail.com>
CooooolFrog
force-pushed
the
feat/grpc-jwt-auth
branch
from
August 13, 2026 08:48
b14ed3d to
93d82c3
Compare
mingcheng
reviewed
Aug 14, 2026
| @@ -0,0 +1,11 @@ | |||
| { | |||
| "_comment": "TEST ONLY. This deterministic key must never be used in a deployment.", | |||
| "secretBase64": "MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY=", | |||
Member
There was a problem hiding this comment.
Although this is a test, I suggest deleting and leaving these parts blank to avoid ambiguity
mingcheng
reviewed
Aug 14, 2026
| } | ||
|
|
||
| if _, ok := keys[config.JWT.ActiveKeyID]; !ok { | ||
| return nil, fmt.Errorf("grpc auth jwt active key id %q is not trusted", config.JWT.ActiveKeyID) |
Member
There was a problem hiding this comment.
It is recommended to uniformly use fmt. Errorf or errors. New to avoid misunderstanding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add optional JWT-based authentication for internal gRPC communication between Dragonfly components.
This change introduces:
disabled: preserves the existing unauthenticated behavior.permissive: sends and validates JWTs while accepting requests without credentials during rolling upgrades.required: rejects requests without a valid JWT.kid-based key rotation.Authentication is disabled by default. When the configuration is omitted or set to
disabled, no key files are required, clients do not attach JWTs, and servers do not authenticate requests.Health checks and local Unix domain socket calls remain unauthenticated.
Related Issue
Related to #4417
Motivation and Context
Internal Dragonfly components currently communicate over gRPC without application-level authentication unless mTLS is enabled.
This change adds token-based authentication using short-lived JWTs signed with a shared secret. It provides an additional authentication option without requiring a PKI or an external token-issuing service.
The
permissivemode supports a simple and backward-compatible first rollout:permissive.required.After a deployment reaches
requiredmode, subsequent compatible releases can use the normal one-step rolling upgrade while keeping authentication enabled.The default
disabledmode ensures that users who do not enable JWT authentication are unaffected.Screenshots (if appropriate)
N/A
Types of changes
Checklist