-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Conversation
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
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]>
Co-authored-by: Julien Salleyron <[email protected]>
6c810d1
to
7472ab7
Compare
@@ -0,0 +1,112 @@ | |||
logLevel = "DEBUG" |
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.
This file should not be commit
middlewares/tlsClientHeaders_test.go
Outdated
for _, certContent := range certContents { | ||
peerCertificates = append(peerCertificates, getCertificate(certContent)) | ||
} | ||
return &tls.ConnectionState{PeerCertificates: peerCertificates} |
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.
Could you please add a new line before?
middlewares/tlsClientHeaders_test.go
Outdated
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") |
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.
Could you please add a new line before ?
middlewares/tlsClientHeaders_test.go
Outdated
} | ||
|
||
for _, test := range testCases { | ||
|
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.
Could you remove this line
middlewares/tlsClientHeaders_test.go
Outdated
for _, test := range testCases { | ||
|
||
sans := getSANs(test.cert) | ||
test := test |
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.
Could you please add a new line before ?
middlewares/tlsClientHeaders_test.go
Outdated
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 { |
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.
Could you please add a new line before ?
provider/label/partial.go
Outdated
@@ -60,6 +60,39 @@ func GetRedirect(labels map[string]string) *types.Redirect { | |||
return nil | |||
} | |||
|
|||
// GetTLSClientCert create tls client header configuration from labels |
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.
// GetTLSClientCert creates TLS client header configuration from labels
instead of // GetTLSClientCert create tls client header configuration from labels
server/server_loadbalancer.go
Outdated
@@ -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) | |||
|
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.
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 |
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.
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 |
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.
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. |
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.
TLS
instead of tls
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 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. |
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.
This line sounds like a forgotten diff when rebasing (it comes from #3797 ). Can you keep it ?
3644792
to
aa15e8d
Compare
Splitting to another PR for doc rebase issues
aa15e8d
to
497b1d4
Compare
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.
Ouch!
Impressive PR with tests and documentation! 👏 👏
LGTM 👍
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 👏
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 pemX-Forwarded-Ssl-Client-Cert-Infos
contains the escaped selected informationsThe options are available in the following providers:
Motivation
Fix the #3052
More
Additional Notes
To test efficiency the client CA files can now be a list of files or contents