-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Support used self-signed certificates LDAP. #1278
Conversation
connector/ldap/ldap.go
Outdated
@@ -68,7 +68,10 @@ type Config struct { | |||
|
|||
// Path to a trusted root certificate file. | |||
RootCA string `json:"rootCA"` | |||
|
|||
// Path to a self-signed certificates ca file. | |||
ClientCA string `json:"clientCA"` |
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.
❓ Wouldn't this mostly match the RootCA
? I'm not sure I understand the usecase where it differs. Can you please elaborate?
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.
If ldap server setting verify client cert is true, only setting RootCA cannot work.
connector/ldap/ldap.go
Outdated
|
||
// Path to a self-signed certificates ca file. | ||
ClientCA string `json:"clientCA"` | ||
//Path to a self-signed certificates private key file. |
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.
[nit] Can we make that // Path
(with a space)?
@veily Thanks for your contribution 😃 |
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.
Thanks for renaming that, I was quite confused 😉
connector/ldap/ldap.go
Outdated
@@ -68,7 +68,10 @@ type Config struct { | |||
|
|||
// Path to a trusted root certificate file. | |||
RootCA string `json:"rootCA"` | |||
|
|||
// Path to a self-signed certificates cert file. |
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.
Can we remove the "self-signed" there? I don't think it is necessary to have self-signed cert here.
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.
Sorry, I am not clear enough. The self-signed certificate is not dex. The ldap server uses a self-signed certificate (RootCA, server cert) and opens the certificate for the client. In this case, if dex Ability to authenticate client certificates through the ldap server, should use client certificates generated by the Ldap server RootCA
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.
http://www.openldap.org/doc/admin24/tls.html
16.1.2. Client Certificates
The DN of a client certificate can be used directly as an authentication DN.
...
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.
without the client certificates, dex all requests to ldap server will be rejected.
Used for LDAP server that used self-signed certificates (RootCA, server cert) and setting TLS verify client. In this case, dex should use the client certificates generated by the Ldap server RootCA. http://www.openldap.org/doc/admin24/tls.html
|
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.
One last nitpick -- then I'd be ok with merging this.
I think this would benefit from having a test case added. The existing ldap connector tests start their own slapd
instance (that's openldap's server), and test different connection methods. I suppose the one added here (using a client cert) could be a good addition.
However, I don't think this has to block this PR. If you feel like the extra tests are too much, we can create an issue for that, an tackle it later.
connector/ldap/ldap.go
Outdated
if c.ClientKey != "" && c.ClientCert != "" { | ||
cert, err := tls.LoadX509KeyPair(c.ClientCert, c.ClientKey) | ||
if err != nil { | ||
return nil, fmt.Errorf("ldap: load self signed certs file failed.error:%s", err) |
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.
[nit] Can we please make that
fmt.Errorf("ldap: load client cert failed: %v", err)
just to be in line with the updated comment (thanks, btw), and the other error printouts above?
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. We can expand our tests in a follow-up.
FYI there are commits that aren't attributed to the author of this PR. Please squash. |
@veily If you need help squashing commits, let me know! Once squashed, and having only you as author, we'll get this in 🎉 |
@srenatus Okay, How squash ? In addition, I used different git username during the completion of this PR, this is my mistake. |
Ah, I see. Could you please squash and do a force push onto your branch
(the one from this pr)? We could then merge it using the normal "merge"
button on github. Just to be in line with how we normally merge things.
|
Update Sorry I was on mobile and hadn't read your reply properly. This is what you'd do in your checkout:
Note that the last line's |
Format ldap.go Format ldap.go: with a space for golint with a space Rename clientCA is to clientCert Update ldap.go modified the ldap client certificate file comments. modified load ldap client cert error. modified load ldap client cert error: fmt.Errorf("ldap: load client cert failed: %v", err)
@srenatus Thanks, I has squashed commits under your guidance. |
Thank you! :) |
Support used self-signed certificates LDAP.
support used self-signed certificates LDAP. #1277