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

Pass the TLS Cert infos in headers #3826

Merged
merged 15 commits into from
Aug 29, 2018

Conversation

jbdoumenjou
Copy link
Member

What does this PR do?

Add a specific option to pass ssl client infos in two specifics headers :

  • X-Forwarded-Ssl-Client-Cert header contains the escaped pem
  • X-Forwarded-Ssl-Client-Cert-Infos contains the escaped selected informations

The options are available in the following providers:

  • File
  • K8s
  • Docker
  • Rancher
  • Consul Catalog
  • Marathon
  • Mesos
  • ECS
  • KV

Motivation

Fix the #3052

More

  • Added/updated tests
  • Added/updated documentation

Additional Notes

To test efficiency the client CA files can now be a list of files or contents

Copy link
Member

@juliens juliens left a comment

Choose a reason for hiding this comment

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

LGTM

jbdoumenjou and others added 7 commits August 28, 2018 09:52
Co-authored-by: Julien Salleyron <[email protected]>
Co-authored-by: Julien Salleyron <[email protected]>
 Co-authored-by: Julien Salleyron <[email protected]>
Co-authored-by: Julien Salleyron <[email protected]>
@@ -0,0 +1,112 @@
logLevel = "DEBUG"
Copy link
Member

Choose a reason for hiding this comment

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

This file should not be commit

for _, certContent := range certContents {
peerCertificates = append(peerCertificates, getCertificate(certContent))
}
return &tls.ConnectionState{PeerCertificates: peerCertificates}
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a new line before?

test := test
t.Run(test.desc, func(t *testing.T) {
t.Parallel()
require.Equal(t, test.expected, sanitize(test.toSanitize), "The sanitized certificates should be equal")
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a new line before ?

}

for _, test := range testCases {

Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this line

for _, test := range testCases {

sans := getSANs(test.cert)
test := test
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a new line before ?

func TestTlsClientheadersWithCertInfos(t *testing.T) {
minimalCertAllInfos := `Subject="C=FR,ST=Some-State,O=Internet Widgits Pty Ltd",NB=1531902496,NA=1534494496,SAN=`
completeCertAllInfos := `Subject="C=FR,ST=SomeState,L=Toulouse,O=Cheese,CN=*.cheese.org",NB=1531900816,NA=1563436816,SAN=*.cheese.org,*.cheese.net,cheese.in,[email protected],[email protected],10.0.1.0,10.0.1.2`
testCases := []struct {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add a new line before ?

@@ -60,6 +60,39 @@ func GetRedirect(labels map[string]string) *types.Redirect {
return nil
}

// GetTLSClientCert create tls client header configuration from labels
Copy link
Member

Choose a reason for hiding this comment

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

// GetTLSClientCert creates TLS client header configuration from labels instead of // GetTLSClientCert create tls client header configuration from labels

@@ -314,7 +313,8 @@ func createClientTLSConfig(entryPointName string, tlsOption *traefiktls.TLS) (*t
if len(tlsOption.ClientCA.Files) > 0 {
pool := x509.NewCertPool()
for _, caFile := range tlsOption.ClientCA.Files {
data, err := ioutil.ReadFile(caFile)

Copy link
Member

Choose a reason for hiding this comment

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

Could you remove this line please

types/types.go Outdated
Sans bool `description:"Add Sans info in header" json:"sans"`
}

// TLSCLientCertificateSubjectInfos holds the client tls certificate subject infos configuration
Copy link
Member

Choose a reason for hiding this comment

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

TLS instead of tls

types/types.go Outdated
Infos *TLSClientCertificateInfos `description:"Enable header with configured client cert infos" json:"infos,omitempty"`
}

// TLSClientCertificateInfos holds the client tls certificate infos configuration
Copy link
Member

Choose a reason for hiding this comment

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

TLS instead of tls

types/types.go Outdated
@@ -611,3 +612,27 @@ func (h HTTPCodeRanges) Contains(statusCode int) bool {
}
return false
}

// TLSClientHeaders holds the tls client cert headers configuration.
Copy link
Member

Choose a reason for hiding this comment

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

TLS instead of tls

Copy link
Contributor

@dduportal dduportal 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 documentation added on basics and user-guide/examples.

However, it sounds like some changes are lost since #3797 : is it because cross branches rebases

@@ -19,7 +19,7 @@ Træfik can be configured to use Docker as a provider.
#
endpoint = "unix:///var/run/docker.sock"

# Default base domain used for the frontend rules.
# Default domain used.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line sounds like a forgotten diff when rebasing (it comes from #3797 ). Can you keep it ?

@jbdoumenjou jbdoumenjou force-pushed the hotfix/clientTLSInfos branch 2 times, most recently from 3644792 to aa15e8d Compare August 28, 2018 08:43
@dduportal dduportal dismissed their stale review August 28, 2018 08:47

Splitting to another PR for doc rebase issues

Copy link
Contributor

@nmengin nmengin left a comment

Choose a reason for hiding this comment

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

Ouch!
Impressive PR with tests and documentation! 👏 👏

LGTM 👍

Copy link
Member

@mmatur mmatur left a comment

Choose a reason for hiding this comment

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

LGTM 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants