Skip to content

Add client certs support and anonymous group search to LDAP#7578

Closed
AeroNotix wants to merge 5 commits into
hashicorp:masterfrom
AeroNotix:add-client-certs
Closed

Add client certs support and anonymous group search to LDAP#7578
AeroNotix wants to merge 5 commits into
hashicorp:masterfrom
AeroNotix:add-client-certs

Conversation

@AeroNotix
Copy link
Copy Markdown

No description provided.

@hashicorp-cla
Copy link
Copy Markdown

hashicorp-cla commented Oct 5, 2019

CLA assistant check
All committers have signed the CLA.

@AeroNotix
Copy link
Copy Markdown
Author

AeroNotix commented Oct 5, 2019

This adds the ability to provide client cert/key files when using LDAP. Some LDAP providers like Google require the use of client certificates for client authentication and being able to perform searches with no bind set. This is how you are required to use the Google LDAP service.

Unknowns:

  • Don't really know if the UI elements are being created correctly, they appear in the UI when I add the fields but I didn't attempt to use them, any pointers will be helpful.

Refs (and probably a few others):

@AeroNotix AeroNotix changed the title Add client certs Add client certs, anonymous group search Oct 6, 2019
@chrishoffman chrishoffman changed the title Add client certs, anonymous group search Add client certs support and anonymous group search to LDAP Oct 8, 2019
@AeroNotix
Copy link
Copy Markdown
Author

Any feedback on this? Am I missing anything? I am willing to support this code in perpetuity (and force my children to do so as well.)

@athieme
Copy link
Copy Markdown

athieme commented Oct 17, 2019

I would need this as well. Is merging this an option?

@AeroNotix
Copy link
Copy Markdown
Author

Any feedback on this?

return nil, logical.ErrorResponse(err.Error()), nil, nil
}

if cfg.AnonymousGroupSearch {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would you mind to explain this part a bit further? The below code is exactly the same we already execute on line 80:

c, err := ldapClient.DialLDAP(cfg.ConfigEntry)
if err != nil {
return nil, logical.ErrorResponse(err.Error()), nil, nil
}
if c == nil {
return nil, logical.ErrorResponse("invalid connection returned from LDAP dial"), nil, nil
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

With google LDAP there's no way to query for groups a user is logged in as while logged in as that user. But there's no way to verify a user's login credentials without binding as that user. At least no way I could find to do it.

Reason I added this was so that you could do the first bind as the logged in user, verify that their credentials are correct - then drop to the anonymous bind with client certificates just for the group membership search.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah, gotcha! That sounds very google LDAP specific to me? I wonder if we should rename anonymous_group_search to google_anonymous_group_search or something similar? anonymous_group_search sounds to me like the credentials are never used at all.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, that makes sense and I agree. I will make that change 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem is if this behavior is ever necessary with an ldap server that isn't Google, now the option name is confusing/limiting.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, @michelvocks made a convincing argument for the name change. I will change it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, and I'm suggesting that it should not be name that was discussed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh my bad, I misunderstood your point then. I'm happy either way, right now we only know that Google LDAP services need this option - but potentially I guess it is possible that others would need it.

Comment thread go.mod
@@ -1,8 +1,6 @@
module github.com/hashicorp/vault

go 1.12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As far as I can see all the changes to go.mod, go.sum and sdk/go.mod are not necessary for this PR. Would you mind to exclude them from your PR?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure, I can. What are the "rules" in general about PRs which bump go/dependency versions?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PRs never bump Go version. But you're out of date from master anyways, it's already updated for Go 1.13.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In general, we bump the go version in a separate PR. Dependency versions can be updated in feature/bugfix PRs if there is reason/advantage to do that.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It wasn't out of date two months ago when I submitted the PR 😛

I'll rebase with master and push up changes.

Copy link
Copy Markdown
Contributor

@michelvocks michelvocks left a comment

Choose a reason for hiding this comment

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

Hi @AeroNotix!

First of all, I want to apologize for the super late reply/review. We are doing our best to do community reviews as quickly as possible but sometimes we struggle a bit.
We really appreciate your work and effort tho!

This PR looks good overall but I have a question and one minor change request left (see in the review). I'm also a bit unsure about the UI question you have mentioned above. I CC here @noelledaley since I think she can help out here.

Cheers,
Michel

@AeroNotix
Copy link
Copy Markdown
Author

Thanks for getting back to me!

The UI changes I refer to are that some of the additional configuration options I added may not be configurable from the UI properly, I did a quick poke around the JS and fragments that add the configuration options to the UI but last I checked they didn't seem to work as expected. It's been a couple of months since I fired up this PR and had it going. When I get time this week I'll rebase w/ master and go through the motions testing it with our Google LDAP set up.

@noelledaley hi - any feedback or tips regarding what's needed for the UI portions is much appreciated!

if err != nil {
return nil, logical.ErrorResponse("ldap operation failed"), nil, nil
}
defer c.Close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you can drop this line since we already added c.Close() to the defer-stack a few lines above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure!

"anonymous_group_search": {
Type: framework.TypeBool,
Default: false,
Description: "Use anonymous binds when performing LDAP group searches",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to add that the credentials are stilled used for the initial connection test otherwise users could be confused.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Can do!

"anonymous_group_search": {
Type: framework.TypeBool,
Default: false,
Description: "Use anonymous binds when performing LDAP group searches",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You'll need to add another property after Description called DisplayAttrs with the field display Name and default Value to get this field to show in the UI. Here's an example of how to do that!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you! Will do.


"client_tls_cert": {
Type: framework.TypeString,
Description: "Client certificate to provide to the LDAP server, must be x509 PEM encoded (optional)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You'll need the DisplayAttrs for this field as well

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks!


"client_tls_key": {
Type: framework.TypeString,
Description: "Client certificate key to provide to the LDAP server, must be x509 PEM encoded (optional)",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

....and this one, too. :)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thank you! Will make these changes.

@andaley
Copy link
Copy Markdown
Contributor

andaley commented Dec 4, 2019

Hi @AeroNotix!

Thanks for including UI changes in this PR! The changes look good to me at an initial glance -- you'll just need to add the DisplayAttrs to get the fields to show up in the UI properly. Once you've done that + rebased, let us know and we can test it out.

Nice work!

Cheers,
Noelle

Copy link
Copy Markdown
Author

@AeroNotix AeroNotix left a comment

Choose a reason for hiding this comment

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

Thanks @noelledaley appreciate the feedback. Will make the changed you requested and push up.

@stephenrjohnson
Copy link
Copy Markdown

So excited for this change and then we can finally connect vault to google for user authentication.

@rodrigorato
Copy link
Copy Markdown

So excited for this change and then we can finally connect vault to google for user authentication.

Yeah, I'm also waiting on this one. Thanks to everyone who is making this possible!

@AeroNotix
Copy link
Copy Markdown
Author

My use-case for vault logins has changed somewhat - I might not be able to get to this to deal with PR comments/review comments.

If you need Vault LDAP logins working with Google - all the work is done and the changes requested shouldn't be much on top of that.

@Gisson Gisson mentioned this pull request Feb 17, 2020
@Gisson
Copy link
Copy Markdown
Contributor

Gisson commented Feb 17, 2020

I've rebased from master and applied the fixes mentioned in the previous review in the PR #8365 . Can we follow up on this there?

@AeroNotix
Copy link
Copy Markdown
Author

@Gisson thanks for taking this on and trying to get it over the line. I'll close this PR in favour of your other.

@AeroNotix AeroNotix closed this Feb 17, 2020
@AeroNotix AeroNotix deleted the add-client-certs branch February 17, 2020 14:03
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.

9 participants