Skip to content
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

xds: client-side security: xDS credentials implementation #3888

Merged
merged 8 commits into from Sep 29, 2020

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Sep 18, 2020

No description provided.

@easwars
Copy link
Contributor Author

easwars commented Sep 18, 2020

@ZhenLian @jiangtaoli2016
Hi Zhen/Jiangtao,
Would really appreciate if you can take a look from security perspective and let me know any comments. Thank you.

@ZhenLian ZhenLian self-requested a review September 21, 2020 07:00
credentials/xds/xds.go Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ZhenLian ZhenLian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the overall API and the security-related code such as handshake, etc.

credentials/xds/xds.go Outdated Show resolved Hide resolved
@easwars
Copy link
Contributor Author

easwars commented Sep 24, 2020

Gentle ping @dfawley

credentials/xds/xds.go Outdated Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
// On the client side, rootProvider is mandatory. IdentityProvider is
// optional based on whether the client is doing TLS or mTLS.
if isClient && chi.rootProvider == nil {
return errors.New("root certificate provider is missing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are going to surface to users IIUC; we should maybe have a better description of what went wrong in that case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would this mean when it happens? It's a programming error on our part? Or a usage error on the user's part? The error should tell the end user what to do: either how to fix the problem or let them know it's a grpc-go bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an extreme edge case I would think where the control plane is not sending us the correct config. So, I have added another line to the error message asking the user to check the control plane config.

credentials/xds/xds.go Outdated Show resolved Hide resolved
credentials/xds/xds.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned easwars and unassigned dfawley Sep 24, 2020
Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating github state

@easwars easwars assigned dfawley and unassigned easwars Sep 24, 2020
Comment on lines 76 to 82
// SetHandshakeInfo returns a copy of attr which is updated with hInfo.
func SetHandshakeInfo(attr *attributes.Attributes, hInfo *HandshakeInfo) *attributes.Attributes {
return attr.WithValues(handshakeAttrKey{}, hInfo)
}

// GetHandshakeInfo returns a pointer to the HandshakeInfo stored in attr.
func GetHandshakeInfo(attr *attributes.Attributes) *HandshakeInfo {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make these work on resolver.Addresses instead of attributes, e.g.:

func Get(addr resolver.Address) []string {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed SetHandshakeInfo to work on resolver.Address since this will be invoked from the CDS balancer and it has a resolver.Address at that point.

GetHandshakeInfo is called from the credentials code, and there is no resolver.Address at that point.

// On the client side, rootProvider is mandatory. IdentityProvider is
// optional based on whether the client is doing TLS or mTLS.
if isClient && chi.rootProvider == nil {
return errors.New("root certificate provider is missing")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would this mean when it happens? It's a programming error on our part? Or a usage error on the user's part? The error should tell the end user what to do: either how to fix the problem or let them know it's a grpc-go bug.

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple small things but otherwise looks great!

@dfawley dfawley assigned easwars and unassigned dfawley Sep 29, 2020
Copy link
Contributor Author

@easwars easwars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL.

@easwars easwars assigned dfawley and unassigned easwars Sep 29, 2020
// updated with hInfo.
func SetHandshakeInfo(addr resolver.Address, hInfo *HandshakeInfo) resolver.Address {
addr.Attributes = addr.Attributes.WithValues(handshakeAttrKey{}, hInfo)
return addr
}

// GetHandshakeInfo returns a pointer to the HandshakeInfo stored in attr.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be unexported? Does anyone else need access to it? If so that would eliminate the asymmetry of the API (setter takes address, getter takes attributes).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dfawley dfawley assigned easwars and unassigned dfawley Sep 29, 2020
@easwars easwars assigned dfawley and unassigned easwars Sep 29, 2020
@dfawley dfawley assigned easwars and unassigned dfawley Sep 29, 2020
@easwars easwars merged commit 6f47205 into grpc:master Sep 29, 2020
@easwars easwars deleted the xds_client_creds branch September 29, 2020 23:39
@easwars easwars changed the title credentials/xds: Implementation of client-side xDS credentials. credentials/xds: client-side PSM security: xDS credentials implementation Mar 4, 2021
@easwars easwars changed the title credentials/xds: client-side PSM security: xDS credentials implementation xds: client-side PSM security: xDS credentials implementation Mar 4, 2021
@easwars easwars changed the title xds: client-side PSM security: xDS credentials implementation xds: client-side security: xDS credentials implementation Mar 4, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants