-
Notifications
You must be signed in to change notification settings - Fork 4.6k
credentials, transport, grpc : add a call option to override the :authority header on a per-RPC basis #8068
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8068 +/- ##
==========================================
- Coverage 82.32% 82.24% -0.08%
==========================================
Files 387 417 +30
Lines 39064 41385 +2321
==========================================
+ Hits 32159 34037 +1878
- Misses 5593 5926 +333
- Partials 1312 1422 +110
🚀 New features to boost your workflow:
|
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.
Overall lgtm. Just few minor comments. I think we can combine some individual into t-tests.
Also, don't feel strongly but may be we can utilize the setup in tls_ext_test or move the tls tests to tls_ext_test.go |
these aren't the release notes. Are they? Release notes needs to make sense to the user which is the new call option we are introducing. So it can be something close to what you have in the PR title. The above bullets can just be moved to PR description. |
rpc_util.go
Outdated
} | ||
func (o MaxRecvMsgSizeCallOption) after(*callInfo, *csAttempt) {} | ||
|
||
// CallAuthority creates a CallOption that sets the HTTP/2 :authority header of |
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 think we should mention here that if this dial option is used, the credentials in use must implement AuthorityValidator
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.
Done.
internal/transport/http2_client.go
Outdated
if callHdr.Authority != "" { | ||
auth, ok := t.authInfo.(credentials.AuthorityValidator) | ||
if !ok { | ||
return nil, &NewStreamError{Err: status.Error(codes.Unavailable, fmt.Sprintf("credentials type %s does not implement the AuthorityValidator interface, but authority override specified with CallAuthority call option", t.authInfo.AuthType()))} |
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.
Same here too. Use status.Errorf
.
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.
And use %q
formatting directive for the credentials type.
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.
done.
internal/transport/http2_client.go
Outdated
return nil, &NewStreamError{Err: status.Error(codes.Unavailable, fmt.Sprintf("credentials type %s does not implement the AuthorityValidator interface, but authority override specified with CallAuthority call option", t.authInfo.AuthType()))} | ||
} | ||
if err := auth.ValidateAuthority(callHdr.Authority); err != nil { | ||
return nil, &NewStreamError{Err: status.Error(codes.Unavailable, fmt.Sprintf("failed to validate authority %s : %s", callHdr.Authority, err))} |
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.
Both the above comments here too. And use %v
for err
.
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.
done.
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.
LGTM modulo minor nits in this last pass
credentials/credentials_ext_test.go
Outdated
if authority == v.validAuthority { | ||
return nil | ||
} | ||
return fmt.Errorf("invalid authority") |
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.
Nit: capture the invalid authority value in the returned error
…hority header on a per-RPC basis (grpc#8068)
…hority header on a per-RPC basis (grpc#8068)
Fixes: #5361
RELEASE NOTES:
CallAuthority
callOption that can be used to overwrite the http:authority
header on per-RPC basis.