Skip to content

Commit 8b5e90b

Browse files
committed
Allow custom cookie domain
1 parent 9640fa4 commit 8b5e90b

File tree

4 files changed

+7
-0
lines changed

4 files changed

+7
-0
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ENV LDAPAUTHD_LOGLEVEL=INFO \
1717
LDAPAUTHD_PORT=80 \
1818
LDAPAUTHD_REALM=Authorization\ required \
1919
LDAPAUTHD_SESSION_STORAGE=memcached \
20+
LDAPAUTHD_SESSION_DOMAIN= \
2021
LDAPAUTHD_SESSION_HOST=sessiondb:11211 \
2122
LDAPAUTHD_SESSION_TTL=900 \
2223
LDAP_LOGLEVEL=ERROR \

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Configuration for this daemon is read from the current environment. Available co
8080
| LDAPAUTHD_USER | User the daemon should be run with. | nobody |
8181
| LDAPAUTHD_REALM | String to set in WWW-Authenticate. | Authorization required |
8282
| LDAPAUTHD_SESSION_STORAGE | Choose session storage backend. Available: memcached | memcached |
83+
| LDAPAUTHD_SESSION_DOMAIN | Set domain for your session cookie. | |
8384
| LDAPAUTHD_SESSION_HOST | Host address of your session storage. | localhost:11211 |
8485
| LDAPAUTHD_SESSION_TTL | Maximum TTL for sessions in seconds. | 900 |
8586
| LDAP_LOGLEVEL | https://ldap3.readthedocs.io/logging.html#logging-detail-level | ERROR |

docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ services:
1919
#- LDAPAUTHD_REALM=Authorization required
2020
# Choose session storage backend. Available: memcached
2121
#- LDAPAUTHD_SESSION_STORAGE=memcached
22+
# Set domain for your session cookie.
23+
#- LDAPAUTHD_SESSION_DOMAIN=
2224
# Host address of your session storage.
2325
#- LDAPAUTHD_SESSION_HOST=sessiondb:11211
2426
# Maximum TTL for sessions in seconds.

ldapauthd.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,8 @@ def do_GET(self):
315315

316316
cookie = SimpleCookie()
317317
cookie["_ldapauthd_sess"] = self.session_id
318+
if cookie_domain:
319+
cookie["_ldapauthd_sess"]["domain"] = cookie_domain
318320

319321
self.send_response(307)
320322
self.send_header("Set-Cookie", cookie["_ldapauthd_sess"].OutputString())
@@ -385,6 +387,7 @@ def to_lower_dict(data):
385387
logging.basicConfig(format="%(asctime)-15s %(name)s [%(levelname)s]: %(message)s")
386388

387389
realm = os.getenv("LDAPAUTHD_REALM", "Authorization required")
390+
cookie_domain = os.getenv("LDAPAUTHD_SESSION_DOMAIN", None)
388391

389392
sessions = SessionHandlerBase.get_handler()
390393
sessions.run()

0 commit comments

Comments
 (0)