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

Connecting to LDAP server without TLS #15

Open
jbperrin88 opened this issue Jun 20, 2019 · 10 comments
Open

Connecting to LDAP server without TLS #15

jbperrin88 opened this issue Jun 20, 2019 · 10 comments
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested

Comments

@jbperrin88
Copy link

Hi there ,

Like some other user , i would like to use your project to forward auth to LDAP server from Traefik .

There is STILL few LDAP server without TLS in my environement (I know..... it's a bit dirty)

When i tried to connect to this kind of server , i got "Failed to connect: LDAP Result Code 1 "Operations Error": ldap: cannot StartTLS (00000000: LdapErr: DSID-0C090E6B, comment: TLS or SSL already in effect, data 0, v1db1\x00)"

Can you please,give me some Tips ? Is it possible ? Do you have some special env ?

Thanks !

@pinepain
Copy link
Owner

Hi @jbperrin88, what is ldap connection string you are using? is it ldap:// protocol or ldaps://?

@pinepain pinepain added the question Further information is requested label Jun 20, 2019
@jbperrin88
Copy link
Author

Woooo , such rapid answer . i'm impress ....

This is my configuration:

environment:
  LOG_LEVEL: "debug"
  LISTEN: ":8888"
  LDAP_SERVER: "ldap://XXX"
  LDAP_BASE: "XXX"
  LDAP_BIND_DN: "XXX"
  LDAP_BIND_PASSWORD: "XXX"
  LDAP_USER_FILTER: "(sAMAccountName=%s)"
  HEADERS_MAP: "X-LDAP-Mail:mail,X-LDAP-UID:sAMAccountName,X-LDAP-CN:cn"

@jbperrin88
Copy link
Author

i've even try to set the port in the connection string LDAP_SERVER: "ldap://XXX:389"

@pinepain
Copy link
Owner

pinepain commented Jun 20, 2019

@jbperrin88 thanks, I'll give it a look, a tls connection shall not be initiated when ldap scheme shall not be triggering TLS start:

https://github.com/pinepain/ldap-auth-proxy/blob/master/ldap.go#L50
https://github.com/pinepain/ldap-auth-proxy/blob/master/ldap.go#L56-L59

@jbperrin88
Copy link
Author

So , i try without Scheme in URL . Same error message .

The log say : cannot StartTLS

Is the 'StartTLS' option is set by default (StartTLS is neither TLS or SSL)

And i used you last docker image from docker Hub .

@pinepain
Copy link
Owner

@jbperrin88 thanks, I'll give it a look, the tls shall not be initiated when ldap scheme is not ldaps.

@jbperrin88
Copy link
Author

Hum look like this : jtblin/go-ldap-client#3

@pinepain
Copy link
Owner

Yeah, looks relevant to me. Anyway, I had in mind to migrate to raw LDAP library (v2 or v3), so it may be a good thing to do.

@jbperrin88
Copy link
Author

Another short question , i'm using Ldap to request windows AD .

How can i used the group filtering method .

if i've understood , i need to find a filter to get all groupe the user belong to (only this the %s -> sAMAccountName) and use the GROUP_HEADER in to set the group i want ?

@pinepain
Copy link
Owner

pinepain commented Jun 25, 2019

Giving that you have export GROUP_HEADER='X-Ldap-Group', set X-Ldap-Group header value to allowed groups. It could be single group or multiple, comma-separated groups. If multiple groups used, user should be at least in one group.

With nginx proxy block it may be sth like this:

    map $host $ldap_group {
        default "UNKNOWN_GROUP";

        "foo.bar" "group1,group2";
        "example.com" "exampleGroup";
    }

...

        location = /auth-proxy {
            internal;

            proxy_pass http://ldap_auth/auth;

            proxy_pass_request_body off;
            proxy_set_header        Content-Length "";
            proxy_cache             auth_cache;
            proxy_cache_valid       202 15m;

            # The following directive adds the cookie to the cache key
            proxy_cache_key "$target_host$http_authorization";

            proxy_set_header X-Ldap-Group $ldap_group;
        }

It is a bit complex example which I use to have single point of auth for multiple hosts. It should give you a perspective how to use groups filtering.

@pinepain pinepain added the bug Something isn't working label Jun 25, 2019
@pinepain pinepain added the good first issue Good for newcomers label Nov 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants