feat: Add native gRPC integration support#377
Open
developerkunal wants to merge 4 commits intomasterfrom
Open
Conversation
Add out-of-the-box gRPC support with unary and streaming interceptors:
- New integrations/grpc package with interceptor implementation
- Token extraction from gRPC metadata (authorization header)
- Custom error handler mapping validation errors to gRPC status codes
- Helper functions for claims retrieval from context
- Support for excluded methods/patterns
- Comprehensive unit tests with 100% coverage
- Complete gRPC example with client/server implementation
- Integration tests for the example
- Updated README with gRPC usage documentation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #377 +/- ##
==========================================
- Coverage 96.55% 96.49% -0.06%
==========================================
Files 18 23 +5
Lines 1508 1713 +205
==========================================
+ Hits 1456 1653 +197
- Misses 34 39 +5
- Partials 18 21 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive native gRPC support to the JWT middleware SDK, enabling seamless JWT authentication for gRPC services through interceptors for both unary and streaming methods.
Changes:
- Introduced gRPC-specific interceptors in
integrations/grpc/package with metadata-based token extraction - Implemented comprehensive error mapping from JWT validation errors to appropriate gRPC status codes
- Added complete test coverage including unit tests, integration tests, and a fully functional example application
Reviewed changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
integrations/grpc/interceptor.go |
Core JWT interceptor implementation for unary and streaming gRPC methods |
integrations/grpc/option.go |
Configuration options with builder pattern for interceptor setup |
integrations/grpc/extractor.go |
Token extraction from gRPC metadata following Bearer token conventions |
integrations/grpc/error_handler.go |
Maps JWT validation errors to appropriate gRPC status codes |
integrations/grpc/claims.go |
Type-safe claims retrieval helpers using generics |
integrations/grpc/doc.go |
Comprehensive package documentation with usage examples |
integrations/grpc/*_test.go |
Extensive unit tests for all components |
examples/grpc-example/ |
Complete working example with server, client, and integration tests |
examples/grpc-example/proto/ |
Protocol Buffer definitions and generated code |
go.mod, go.sum |
Added gRPC dependencies (v1.78.0) |
README.md |
Updated main documentation with gRPC usage examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 task
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
This PR adds native gRPC support to the JWT middleware SDK, providing out-of-the-box integration for both unary and streaming gRPC methods.
Changes
integrations/grpc/Usage Example
References
#181
Testing