Skip to content

Add Documentation About Docker #2

Open

Description

@benyanke

From @benyanke on April 23, 2018 4:3

#19 added an alpine Dockerfile for building and running (yay) is merged into dev, eventually into master once it's been more tested. Eventually, this will link to a docker hub automated build for easy deployment and use.

However, no documentation in the README.md file yet! This needs to be done.

Documentation would need to include, at minimum:

  • How to mount a volume for a config file (mount /app/config/config.cfg to override the default one)
  • How to forward ports

Copied from original issue: nmcclain/glauth#20

Activity

  1. added
    enhancement
    good first issue
    on Apr 25, 2018
  2. sikmir commented on Oct 27, 2018

    @sikmir

    I'm trying to get it working, but have some problem:

    $ docker pull glauth/glauth:v1.1.0
    $ docker volume create glauth-config
    $ cat << EOF > /var/lib/docker/volumes/glauth-config/_data/config.cfg
    [frontend]
      tls = false
      listen = "0.0.0.0:3893"
    [backend]
      datastore = "config"
      baseDN = "dc=example,dc=com"
    [[users]]
      ...
    [[groups]]
      ...
    [api]
      enabled = false
    EOF
    $ cat << EOF > docker-compose.yml
    version: '2'
    services:
      ldap:
        image: glauth/glauth:v1.1.0
        container_name: ldap
        ports:
          - 389:389
          - 3893:3893
          - 636:636
        volumes:
          - glauth-config:/app/config
    volumes:
      glauth-config:
        external: true
    EOF
    $ docker-compose up -d
    $ docker-compose logs ldap
    ldap                 | GLauth v1.1.0
    ldap                 | 
    ldap                 | Build time: 20180922_033525Z
    ldap                 | Commit: 3a513c4ee62804b6410b31dcb4840c5af7c9af4e
    ldap                 | 
    ldap                 | 18:19:26.376624 main ▶ NOTI 001 Using config backend
    ldap                 | 18:19:26.381259 main ▶ NOTI 002 Frontend LDAP server listening on 0.0.0.0:3893
    $ docker exec -it ldap sh -c "netstat -lptun"
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
    tcp        0      0 127.0.0.11:37081        0.0.0.0:*               LISTEN      -
    tcp        0      0 :::3893                 :::*                    LISTEN      11/glauth
    udp        0      0 127.0.0.11:33541        0.0.0.0:*                           -

    So, the question is why 389 and 636 ports are closed? Log says nothing.
    @benyanke Could you please take a look?

  3. benyanke commented on Oct 29, 2018

    @benyanke
    MemberAuthor

    Sure - this is just your use of the config file vs docker compose (in other words - everything working as intended).

    In frontend.listen, you specify the bind address for plaintext LDAP as 0.0.0.0:3893. This means that inside the container, 3893 is the only bound port.

    If you update that to 0.0.0.0:389, it'll start listening over port 389 for plaintext LDAP queries.

  4. sikmir commented on Oct 29, 2018

    @sikmir

    Thanks, I was mistaken about what [frontend] actually is. I should use [ldap] and [ldaps] config sections instead, it's much more clear.
    config.cfg:

    [ldap]
      enabled = true
      listen = "0.0.0.0:389"
    [ldaps]
      enabled = true
      listen = "0.0.0.0:636"
      cert = "/etc/glauth/certs/cert.pem"
      key = "/etc/glauth/certs/key.pem"
    [backend]
      datastore = "config"
      baseDN = "dc=example,dc=com"
    [[users]]
      ...
    [[groups]]
      ...
    [api]
      enabled = false

    docker-compose.yml:

    version: '2'
    services:
      ldap:
        image: glauth/glauth:v1.1.0
        container_name: ldap
        ports:
          - 389:389
          - 636:636
        volumes:
          - certs:/etc/glauth/certs:ro
          - glauth-config:/app/config
    volumes:
      certs:
        external: true
      glauth-config:
        external: true

    But, still some problem:

    $ docker-compose up -d
    $ docker-compose logs ldap
    ldap                 | GLauth v1.1.0
    ldap                 | 
    ldap                 | Build time: 20180922_033525Z
    ldap                 | Commit: 3a513c4ee62804b6410b31dcb4840c5af7c9af4e
    ldap                 | 
    ldap                 | 06:41:27.193917 main ▶ NOTI 001 Using config backend
    ldap                 | 06:41:27.194430 main ▶ NOTI 002 Frontend LDAPS server listening on 
    ldap                 | 06:41:27.194684 main ▶ CRIT 003 LDAP Server Failed: open : no such file or directory
    $ docker run --rm -v certs:/etc/glauth/certs -v glauth-config:/app/config -it glauth/glauth:v1.1.0 sh
    /go # ls /etc/glauth/certs/
    cert.pem          key.pem

    What is "no such file or directory" for here?

  5. benyanke commented on Oct 29, 2018

    @benyanke
    MemberAuthor

    That's because you haven't created your certs and placed them there - glauth doesn't generate certs, it just uses them.

  6. sikmir commented on Oct 29, 2018

    @sikmir

    That's because you haven't created your certs and placed them there - glauth doesn't generate certs, it just uses them.

    No, I've generated them in advance:

    $ docker run --rm -v certs:/etc/glauth/certs -v glauth-config:/app/config -it glauth/glauth:v1.1.0 sh
    /go # ls /etc/glauth/certs/
    cert.pem          key.pem
  7. benyanke commented on Oct 29, 2018

    @benyanke
    MemberAuthor

    I'd check permissions next. Try (JUST FOR TESTING) to set them to chmod 777 to see if they're readable then.

  8. sikmir commented on Oct 29, 2018

    @sikmir

    I'd check permissions next. Try (JUST FOR TESTING) to set them to chmod 777 to see if they're readable then.

    $ docker run --rm -v certs:/etc/glauth/certs -v glauth-config:/app/config -it glauth/glauth:v1.1.0 sh
    /go # ls -la /etc/glauth/certs/
    ...
    -rwxrwxrwx    1 root     root          2499 Oct 27 17:53 cert.pem
    -rwxrwxrwx    1 root     root          3267 Oct 27 17:53 key.pem

    By the way, it would be helpful to add file name to log string: "LDAP Server Failed: open : no such file or directory". Otherwise I'm not sure that it complains about cert files, because the prefix is "LDAP Server", not "LDAPS Server".

  9. sikmir commented on Nov 17, 2018

    @sikmir

    I've removed [ldaps] section from config, and result is the same:

    ldap                 | GLauth v1.1.0
    ldap                 | 
    ldap                 | Build time: 20180922_033525Z
    ldap                 | Commit: 3a513c4ee62804b6410b31dcb4840c5af7c9af4e
    ldap                 | 
    ldap                 | 20:17:25.831080 main ▶ NOTI 001 Using config backend
    ldap                 | 20:17:25.831262 main ▶ NOTI 002 Frontend LDAPS server listening on 
    ldap                 | 20:17:25.831330 main ▶ CRIT 003 LDAP Server Failed: open : no such file or directory

    So, why GLAuth starts LDAPS server anyway?

  10. darkguy2008 commented on May 12, 2019

    @darkguy2008

    I had success with this:

    docker-compose.yml:

    version: '3'
    services:
      glauth:
        image: glauth/glauth
        ports:
          - 389:389
          - 636:636
        volumes:
          - /home/user/.acme.sh/domain.com:/app/config/certs
          - ./config.cfg:/app/config/config.cfg
    

    config.cfg

    debug = true
    
    [ldap]
      enabled = true
      listen = "0.0.0.0:389"
    
    [ldaps]
      enabled = true
      listen = "0.0.0.0:636"
      cert = "/app/config/certs/domain.com.cer"
      key = "/app/config/certs/domain.com.key"
    
    [backend]
      datastore = "config"
      baseDN = "dc=domain,dc=com"
    
    # echo -n "mysecret" | openssl dgst -sha256
    
    [[users]]
      name = "jdoe"
      givenname="John"
      sn="Doe"
      mail = "[email protected]"
      unixid = 5000
      primarygroup = 6000
      passsha256 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    
    [[groups]]
      name = "admins"
      unixid = 6000
    
    [[groups]]
      name = "users"
      unixid = 6001
    

    Test credentials:

    host: domain.com
    port: 389
    version: 3
    Base DN: dc=domain,dc=com
    Bind DN (username): jdoe,ou=admins,dc=domain,dc=com
    

    Quite cryptic, if I say the least.

    Documentation is really scarse though. I'm concerned about user permissions: How do I set up admin users (those who I can connect with an LDAP admin app like Softerra's) to make changes, but avoid the other users I create with them (at least as a basic feature) to alter the users/server as well?

  11. matttrach commented on Sep 20, 2019

    @matttrach

    Quick reference:

    1. get the container docker pull glauth/glauth
    2. make yourself a workspace mkdir ldap; cd ldap; mkdir certs;
    3. self-sign a cert
      cd certs; openssl req -newkey rsa:2048 -nodes -keyout domain.com.key -x509 -days 365 -out domain.com
    4. encrypt a pasword echo -n "mysecret" | openssl dgst -sha256
    5. copy darkguy2008's config into simple.cfg
    debug = true
    
    [ldap]
      enabled = true
      listen = "0.0.0.0:389"
    
    [ldaps]
      enabled = true
      listen = "0.0.0.0:636"
      cert = "/app/config/certs/domain.com"
      key = "/app/config/certs/domain.com.key"
    
    [backend]
      datastore = "config"
      baseDN = "dc=domain,dc=com"
    
    [[users]]
      name = "jdoe"
      givenname="John"
      sn="Doe"
      mail = "[email protected]"
      unixid = 5000
      primarygroup = 6000
      passsha256 = "xxxxxxxxxxx" # response from echo above
    
    [[groups]]
      name = "admins"
      unixid = 6000
    
    [[groups]]
      name = "users"
      unixid = 6001
    
    1. run the docker container (detached)
      docker run -d --rm --name ldap -p 389:389 -p 636:636 -v $PWD/certs:/app/config/certs -v $PWD/simple.cfg:/app/config/config.cfg glauth/glauth
    2. install ldap utils
      apt install ldap-utils
    3. search
      ldapsearch -D "cn=jdoe,ou=admins,dc=domain,dc=com" -w mysecret -p 389 -h localhost -b "dc=domain,dc=com" -s sub "(objectclass=*)"
  12. added a commit that references this issue on Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationenhancementgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions