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

Add client cert authentication #6190

Merged
merged 1 commit into from Apr 1, 2015

Conversation

liggitt
Copy link
Member

@liggitt liggitt commented Mar 30, 2015

No description provided.

@googlebot
Copy link

Thanks for your pull request.

It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA) at https://cla.developers.google.com/.

If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check the information on your CLA or see this help article on setting the email on your git commits.

Once you've done that, please reply here to let us know. If you signed the CLA as a corporation, please let us know the company's name.

@liggitt liggitt force-pushed the client_cert_auth branch 2 times, most recently from 43279fc to d4b79ca Compare March 30, 2015 21:29
@vmarmol
Copy link
Contributor

vmarmol commented Mar 30, 2015

Assigning to @erictune, I think you'd know who to better assign to if you need to rebalance :)

@roberthbailey
Copy link
Contributor

Yoink. I was actually going to add this in a few days so I'll take a look.

if block == nil {
break
}
if block.Type != "CERTIFICATE" || len(block.Headers) != 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does it mean if there are no headers? You don't use the headers anywhere below.

Can you add a comment why we skip blocks w/o headers?

Copy link
Member Author

Choose a reason for hiding this comment

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

It means that CertPool#AppendCertsFromPEM would not add it :)
http://golang.org/src/crypto/x509/cert_pool.go?s=2159:2223#L75

It means that only PEM "CERTIFICATE" blocks without extra headers get parsed as CA certificates

@liggitt
Copy link
Member Author

liggitt commented Mar 31, 2015

comments addressed

@liggitt
Copy link
Member Author

liggitt commented Mar 31, 2015

looks like travis blipped

@liggitt liggitt force-pushed the client_cert_auth branch 2 times, most recently from e017026 to 23a182c Compare March 31, 2015 15:27
@roberthbailey
Copy link
Contributor

LGTM. Will give @erictune a chance to weigh in before merging.

@@ -139,6 +140,7 @@ func (s *APIServer) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&s.CloudProvider, "cloud_provider", s.CloudProvider, "The provider for cloud services. Empty string for no provider.")
fs.StringVar(&s.CloudConfigFile, "cloud_config", s.CloudConfigFile, "The path to the cloud provider configuration file. Empty string for no configuration file.")
fs.DurationVar(&s.EventTTL, "event_ttl", s.EventTTL, "Amount of time to retain events. Default 1 hour.")
fs.StringVar(&s.ClientCAFile, "client_ca_file", s.ClientCAFile, "If set, the file that will be used to secure the secure port of the API server via client cert authentication.")
Copy link
Member

Choose a reason for hiding this comment

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

Would it be correct to say: "If set, any client presenting a cert signed by the CA in client_ca_file is authenticated with an identity corresponding to the CN of the client cert."

If so, I think that is a clearer flag description.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup, updated

// This allows certificates to be validated by authenticators, while still allowing other auth types
secureServer.TLSConfig.ClientAuth = tls.RequestClientCert
// Specify allowed CAs for client certificates
secureServer.TLSConfig.ClientCAs = clientCAs
Copy link
Member

Choose a reason for hiding this comment

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

What if I am accessing the apiserver via my browser and I have installed a client cert from a CA which is not in the clientCAs pool? Then I automatically get rejected. That seems wrong.

If we tried to expand the clientCAs pool to include our cluster's CA plus all known trustworthy CAs, then it would mean that anyone with a client cert from any of those CAs could authenticate to our cluster, which is also not good.

So, I think the set of allowed client CAs needs to be broader than the set of automatically-authenticating client CAs.

Copy link
Member

Choose a reason for hiding this comment

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

If there is a way to set the TLSConfig to allow connections with any cert, and do all the checking in the Authenticator, then I think that is the way to go for now?

Copy link
Member Author

Choose a reason for hiding this comment

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

You won't get rejected.

Setting ClientAuth=RequestClientCert means a client cert is requested, but not required or validated at the connection level.

Setting ClientCAs tells clients what CAs are valid to present client certificates for. If your browser doesn't have any client certificates for that CA, it won't send any. Leaving ClientCAs blank means some browsers will try to send any client cert they have.

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is a way to set the TLSConfig to allow connections with any cert, and do all the checking in the Authenticator, then I think that is the way to go for now?

That's exactly what this does. See "This allows certificates to be validated by authenticators, while still allowing other auth types" comment :)

Requests without client certs, with invalid client certs, or with valid client certs are all allowed at the transport layer.

Requests without a client cert will skip the client cert Authenticator.
Requests with an "invalid" client cert will fail the client cert Authenticator, but could still get an identity from the token Authenticator.
Requests with a valid client cert will get an identity from the client cert Authenticator.

@erictune
Copy link
Member

erictune commented Apr 1, 2015

I just have the one area that I think needs a change.

@erictune
Copy link
Member

erictune commented Apr 1, 2015

LGTM

roberthbailey added a commit that referenced this pull request Apr 1, 2015
@roberthbailey roberthbailey merged commit 22d9c67 into kubernetes:master Apr 1, 2015
@liggitt liggitt deleted the client_cert_auth branch April 13, 2015 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants