Skip to content

Commit

Permalink
Allow custom cookie domain
Browse files Browse the repository at this point in the history
  • Loading branch information
g0dsCookie committed May 17, 2019
1 parent 9640fa4 commit 8b5e90b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ ENV LDAPAUTHD_LOGLEVEL=INFO \
LDAPAUTHD_PORT=80 \
LDAPAUTHD_REALM=Authorization\ required \
LDAPAUTHD_SESSION_STORAGE=memcached \
LDAPAUTHD_SESSION_DOMAIN= \
LDAPAUTHD_SESSION_HOST=sessiondb:11211 \
LDAPAUTHD_SESSION_TTL=900 \
LDAP_LOGLEVEL=ERROR \
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Configuration for this daemon is read from the current environment. Available co
| LDAPAUTHD_USER | User the daemon should be run with. | nobody |
| LDAPAUTHD_REALM | String to set in WWW-Authenticate. | Authorization required |
| LDAPAUTHD_SESSION_STORAGE | Choose session storage backend. Available: memcached | memcached |
| LDAPAUTHD_SESSION_DOMAIN | Set domain for your session cookie. | |
| LDAPAUTHD_SESSION_HOST | Host address of your session storage. | localhost:11211 |
| LDAPAUTHD_SESSION_TTL | Maximum TTL for sessions in seconds. | 900 |
| LDAP_LOGLEVEL | https://ldap3.readthedocs.io/logging.html#logging-detail-level | ERROR |
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ services:
#- LDAPAUTHD_REALM=Authorization required
# Choose session storage backend. Available: memcached
#- LDAPAUTHD_SESSION_STORAGE=memcached
# Set domain for your session cookie.
#- LDAPAUTHD_SESSION_DOMAIN=
# Host address of your session storage.
#- LDAPAUTHD_SESSION_HOST=sessiondb:11211
# Maximum TTL for sessions in seconds.
Expand Down
3 changes: 3 additions & 0 deletions ldapauthd.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,8 @@ def do_GET(self):

cookie = SimpleCookie()
cookie["_ldapauthd_sess"] = self.session_id
if cookie_domain:
cookie["_ldapauthd_sess"]["domain"] = cookie_domain

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

realm = os.getenv("LDAPAUTHD_REALM", "Authorization required")
cookie_domain = os.getenv("LDAPAUTHD_SESSION_DOMAIN", None)

sessions = SessionHandlerBase.get_handler()
sessions.run()
Expand Down

0 comments on commit 8b5e90b

Please sign in to comment.