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

internal: Initial support for external client cert validation #2250

Merged
merged 1 commit into from
Mar 21, 2020

Conversation

tsaarni
Copy link
Member

@tsaarni tsaarni commented Feb 19, 2020

internal: Initial support for external client cert validation

Adds initial support for authentication of external clients (downstream) by
validating their client certificates against trusted CA certificate.

The feature is not yet exposed in the API.

Signed-off-by: Tero Saarni tero.saarni@est.tech

@tsaarni tsaarni force-pushed the client-authentication branch from 8975f95 to 52cc094 Compare February 19, 2020 15:52
@tsaarni tsaarni changed the title WIP External client authentication WIP External client certificate validation Feb 19, 2020
@codecov
Copy link

codecov bot commented Feb 19, 2020

Codecov Report

Merging #2250 into master will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2250      +/-   ##
==========================================
+ Coverage   77.97%   78.10%   +0.12%     
==========================================
  Files          60       60              
  Lines        5204     5225      +21     
==========================================
+ Hits         4058     4081      +23     
+ Misses       1058     1057       -1     
+ Partials       88       87       -1     
Impacted Files Coverage Δ
internal/contour/listener.go 92.45% <100.00%> (+0.29%) ⬆️
internal/dag/builder.go 92.69% <100.00%> (ø)
internal/dag/dag.go 93.15% <100.00%> (+0.84%) ⬆️
internal/envoy/auth.go 100.00% <100.00%> (ø)
internal/envoy/cluster.go 100.00% <100.00%> (ø)
internal/envoy/listener.go 95.06% <100.00%> (-0.07%) ⬇️
internal/featuretests/envoy.go 100.00% <100.00%> (ø)
internal/dag/cache.go 96.14% <0.00%> (+0.70%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d09d414...a5e9a96. Read the comment docs.

@tsaarni
Copy link
Member Author

tsaarni commented Feb 19, 2020

This PR replaces #1226 by @uablrek.

I'm submitting this as a draft in order to ask for direction. @jpeach: in design doc review #1233 you mentioned

LGTM, with the proviso that in the final implementation, the upstream and downstream validation fields should use the same struct (i.e. the one currently named "UpstreamValidation").

In the UpstreamValidation we have validation of both CA and subjectName (or rather: Subject Alt Name). The latter is not included in design/tls-client-verification.md since we wanted to minimize the feature as much possible. I think I need two separate types in apis/projectcontour/v1/httpproxy.go: UpstreamValidation with subjectName and DownstreamValidation without?

I have however combined these into single ValidationContext in internal/dag/dag.go.

Another alternative could be to include subjectName validation also for downstream, but from usage perspective it should rather be a list of 0-N client subjectNames, instead of single mandatory one, like it is for upstream.

If we agree to keep two different types in httpproxy.go, I will then add similar test cases for DownstreamValidation everywhere I find tests for UpstreamValidation. For now the test coverage dropped because of this.

Obviously any other comments are of course welcome too!

@jpeach jpeach self-assigned this Feb 19, 2020
@jpeach
Copy link
Contributor

jpeach commented Feb 19, 2020

Thanks @tsaarni; I'll review, but will need a few days to block out the time :)

@davecheney
Copy link
Contributor

Thank you all for your discussion. With my tech lead hat on I do need to remind everyone that the policy of this project is to talk, then code. We should not be designing features by duking it out in PR comments, that is not how we work on this project.

Thank you

@jpeach
Copy link
Contributor

jpeach commented Feb 20, 2020 via email

@davecheney
Copy link
Contributor

Oops, I am terribly sorry I mistook the discussion for the other auth discussions in fly at the moment. Please ignore me

@jpeach
Copy link
Contributor

jpeach commented Feb 20, 2020 via email

@tsaarni
Copy link
Member Author

tsaarni commented Feb 28, 2020

I wonder if you would have time to provide any feedback for me? Thank you! :)

@jpeach
Copy link
Contributor

jpeach commented Feb 28, 2020 via email

Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

Overall, I think this is pretty solid. I had a number of comments about style and so forth, so it might be easier to address some of those in small, separate PRs. I expect probably 2 more review passes. We can land docs towards the end of the review, or file a separate issue for that if you prefer.

apis/projectcontour/v1/httpproxy.go Outdated Show resolved Hide resolved
internal/dag/dag.go Outdated Show resolved Hide resolved
internal/dag/dag.go Outdated Show resolved Hide resolved
internal/envoy/listener.go Outdated Show resolved Hide resolved
internal/envoy/listener_test.go Show resolved Hide resolved
internal/dag/dag.go Show resolved Hide resolved
apis/projectcontour/v1/httpproxy.go Outdated Show resolved Hide resolved
internal/dag/builder.go Outdated Show resolved Hide resolved
internal/envoy/auth.go Outdated Show resolved Hide resolved
internal/envoy/auth.go Outdated Show resolved Hide resolved
Copy link
Contributor

@jpeach jpeach left a comment

Choose a reason for hiding this comment

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

This PR is in good shape, I just had a few small comments around style and improving documentation and so forth.

The last main thing that I think we need to do is add a test into internal/featuretests/. Using one of the existing files as a stating point, you can add a new file downstreamvalidation_test.go. These tests let you simulate updating Kubernetes objects and assert that the final envoy configuration is what you expect. You can also verify Kubernetes object status (valid or invalid).

internal/contour/listener.go Outdated Show resolved Hide resolved
internal/envoy/auth.go Outdated Show resolved Hide resolved
internal/envoy/auth_test.go Outdated Show resolved Hide resolved
internal/envoy/cluster_test.go Outdated Show resolved Hide resolved
internal/contour/listener_test.go Outdated Show resolved Hide resolved
internal/featuretests/kubernetes.go Outdated Show resolved Hide resolved
apis/projectcontour/v1/httpproxy.go Outdated Show resolved Hide resolved
apis/projectcontour/v1/httpproxy.go Outdated Show resolved Hide resolved
internal/dag/builder.go Outdated Show resolved Hide resolved
internal/envoy/listener_test.go Show resolved Hide resolved
@jpeach
Copy link
Contributor

jpeach commented Mar 17, 2020

@tsaarni The lint check failure should go away if you rebase to pick up the tooling script changes.

@jpeach jpeach marked this pull request as ready for review March 17, 2020 22:49
@tsaarni tsaarni force-pushed the client-authentication branch from feb7a6a to 561b557 Compare March 18, 2020 09:41
@tsaarni
Copy link
Member Author

tsaarni commented Mar 18, 2020

I have prepared a commit that removes the API parts until #2347 is resolved. In case you would still like to review this PR as "complete", I will not add that commit here in this PR until you confirm it is OK.

@jpeach
Copy link
Contributor

jpeach commented Mar 20, 2020

I have prepared a commit that removes the API parts until #2347 is resolved. In case you would still like to review this PR as "complete", I will not add that commit here in this PR until you confirm it is OK.

Please go ahead and apply the commit to remove the API. Then, please squash commits, remove the "WIP" tag and update the PR subject to describe the current content of the commit. I'll commit the result.

Don't forget to rebase :)

Adds initial support for authentication of external clients (downstream) by
validating their client certificates against trusted CA certificate.

The feature is not yet exposed in the API.

Signed-off-by: Tero Saarni <tero.saarni@est.tech>
@tsaarni tsaarni force-pushed the client-authentication branch from 561b557 to a5e9a96 Compare March 20, 2020 06:40
@tsaarni tsaarni changed the title WIP External client certificate validation External client certificate validation Mar 20, 2020
@tsaarni tsaarni changed the title External client certificate validation internal: Initial support for external client cert validation Mar 20, 2020
@tsaarni
Copy link
Member Author

tsaarni commented Mar 20, 2020

Thanks! API removed, commits squashed, rebased and renamed!

Just as a reference in case needed, the API changes are stored on this unsquashed fork/branch https://github.com/Nordix/contour/tree/client-authentication-no-squash

@jpeach jpeach merged commit e1d3919 into projectcontour:master Mar 21, 2020
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.

3 participants