-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add tls and api key authentication support #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8669f96
feat: add tls and api key authentication support
vieiralucas 263f968
fix: address cubic review findings for tls/auth support
vieiralucas 1143d0e
fix: apply spotless formatting
vieiralucas 87bd3b0
fix: revert path-based binary check to preserve tls test skip behavio…
vieiralucas ee286e7
fix: address remaining cubic review findings
vieiralucas 8bd03bb
feat: add system trust store support via withTls()
vieiralucas 82eef1c
fix: keep FilaException for client cert validation error
vieiralucas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package dev.faisca.fila; | ||
|
|
||
| import io.grpc.CallOptions; | ||
| import io.grpc.Channel; | ||
| import io.grpc.ClientCall; | ||
| import io.grpc.ClientInterceptor; | ||
| import io.grpc.ForwardingClientCall.SimpleForwardingClientCall; | ||
| import io.grpc.Metadata; | ||
| import io.grpc.MethodDescriptor; | ||
|
|
||
| /** | ||
| * gRPC client interceptor that attaches a {@code Bearer} API key to the {@code authorization} | ||
| * metadata header on every outgoing RPC. | ||
| */ | ||
| final class ApiKeyInterceptor implements ClientInterceptor { | ||
| private static final Metadata.Key<String> AUTH_KEY = | ||
| Metadata.Key.of("authorization", Metadata.ASCII_STRING_MARSHALLER); | ||
|
|
||
| private final String headerValue; | ||
|
|
||
| ApiKeyInterceptor(String apiKey) { | ||
| this.headerValue = "Bearer " + apiKey; | ||
| } | ||
|
|
||
| @Override | ||
| public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall( | ||
| MethodDescriptor<ReqT, RespT> method, CallOptions callOptions, Channel next) { | ||
| return new SimpleForwardingClientCall<>(next.newCall(method, callOptions)) { | ||
| @Override | ||
| public void start(Listener<RespT> responseListener, Metadata headers) { | ||
| headers.put(AUTH_KEY, headerValue); | ||
| super.start(responseListener, headers); | ||
| } | ||
| }; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Unauthenticated
CreateApiKeycan create superadmin keys. Since this RPC bypasses auth (per the comment), any network-reachable client can callCreateApiKey(is_superadmin=true)and obtain a key that bypasses all ACL checks. Consider restricting the unauthenticated bootstrap path—e.g., only allow it when no keys exist yet, or disallowis_superadminon unauthenticated calls—so that an open bootstrap endpoint cannot be exploited post-setup.Prompt for AI agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a server-side authorization concern, not a client SDK issue. The Fila server handles this through the bootstrap_apikey mechanism: when auth is enabled, CreateApiKey requires a valid bootstrap key (configured via config or env var). The proto definition must match the server's proto — changing it here would break compatibility. The SDK is just a client; it doesn't make authorization decisions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I've saved this as a new learning to improve future reviews.