-
Notifications
You must be signed in to change notification settings - Fork 4.8k
xds: Implement GrpcService parsing and shared side channels (gRFC A102) #9319
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
Open
mbissa
wants to merge
6
commits into
grpc:master
Choose a base branch
from
mbissa:pr4-rebased
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,671
−322
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e0b6447
xds: add grpcservice package and Config.AllowedGrpcService lookup
mbissa fef7829
grpcservice: align with finalized AllowedGRPCService API
mbissa 9662c23
filter wiring for A102
mbissa 979d438
address review comments: use imetadata validation and mirror clientco…
mbissa d3b9bc9
address review comments: make grpcservice a pure parser, relocate acc…
mbissa 7bdfc36
review comments
mbissa 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
|
easwars marked this conversation as resolved.
|
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,71 @@ | ||
| /* | ||
| * | ||
| * Copyright 2026 gRPC authors. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| */ | ||
|
|
||
| // Package accesstokencreds implements static access token CallCredentials for | ||
| // xDS-configured side channels, as specified in gRFC A102. | ||
| package accesstokencreds | ||
|
|
||
| import ( | ||
| "context" | ||
| "encoding/json" | ||
| "fmt" | ||
|
|
||
| "google.golang.org/grpc/credentials" | ||
| ) | ||
|
|
||
| // NewCallCredentials returns call credentials that attach a static bearer | ||
| // token to outgoing RPCs. The config must be a JSON object of the form | ||
| // {"token": <non-empty string>}. | ||
| // | ||
| // The credentials require transport security: the token is only ever sent on | ||
| // connections that provide privacy and integrity, and RPCs on weaker | ||
| // connections fail. | ||
| func NewCallCredentials(configJSON json.RawMessage) (credentials.PerRPCCredentials, error) { | ||
| var cfg struct { | ||
| Token string `json:"token"` | ||
| } | ||
| if err := json.Unmarshal(configJSON, &cfg); err != nil { | ||
| return nil, fmt.Errorf("failed to unmarshal access token call credentials config: %v", err) | ||
| } | ||
| if cfg.Token == "" { | ||
| return nil, fmt.Errorf("token is required in access token call credentials config") | ||
| } | ||
| return &callCreds{token: cfg.Token}, nil | ||
| } | ||
|
|
||
| // callCreds implements credentials.PerRPCCredentials by attaching a static | ||
| // bearer token to each RPC. | ||
| type callCreds struct { | ||
| token string | ||
| } | ||
|
|
||
| // GetRequestMetadata returns the token as an authorization header. It fails | ||
| // if the connection does not provide privacy and integrity. | ||
| func (c *callCreds) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) { | ||
| ri, _ := credentials.RequestInfoFromContext(ctx) | ||
| if err := credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity); err != nil { | ||
| return nil, fmt.Errorf("unable to transfer access token PerRPCCredentials: %v", err) | ||
| } | ||
| return map[string]string{"authorization": "Bearer " + c.token}, nil | ||
| } | ||
|
|
||
| // RequireTransportSecurity indicates whether the credentials requires | ||
| // transport security. | ||
| func (c *callCreds) RequireTransportSecurity() bool { | ||
| return true | ||
| } |
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.
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.
I don't think it is reasonable for the bootstrap package to have a dependency on the something inside of the
grpcservicepackage. It wouldn't be reasonable for this package to have a dependency on thegrpcservicepackage as well.