From a22a61e9120199fde110b81b6367750d6587913d Mon Sep 17 00:00:00 2001 From: aptalca Date: Tue, 8 Sep 2020 08:56:55 -0400 Subject: [PATCH] fix form action (POST address) --- README.md | 1 + readme-vars.yml | 1 + root/app/ldap-backend-app.py | 18 +++++++++++------- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d7d00df..c742a86 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 ## Versions +* **08.09.20:** - Set form action correctly. * **30.07.20:** - Fix bug related to unset optional `CERTFILE` and `KEYFILE` vars. * **27.07.20:** - Add support for HTTP over SSL (HTTPS). * **21.07.20:** - Add support for optional user defined fernet key. diff --git a/readme-vars.yml b/readme-vars.yml index 6ff1ab1..a005759 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -43,6 +43,7 @@ app_setup_block: | # changelog changelogs: + - { date: "08.09.20:", desc: "Set form action correctly." } - { date: "30.07.20:", desc: "Fix bug related to unset optional `CERTFILE` and `KEYFILE` vars." } - { date: "27.07.20:", desc: "Add support for HTTP over SSL (HTTPS)." } - { date: "21.07.20:", desc: "Add support for optional user defined fernet key." } diff --git a/root/app/ldap-backend-app.py b/root/app/ldap-backend-app.py index 49d230c..30a7b75 100644 --- a/root/app/ldap-backend-app.py +++ b/root/app/ldap-backend-app.py @@ -2,12 +2,12 @@ ''''which python >/dev/null && exec python "$0" "$@" # ''' # Copyright (C) 2014-2015 Nginx, Inc. -# Copyright (C) 2018 LinuxServer.io +# Copyright (C) 2018-2020 LinuxServer.io # Example of an application working on port 9000 # To interact with nginx-ldap-auth-daemon this application -# 1) accepts GET requests on /login and responds with a login form -# 2) accepts POST requests on /login, sets a cookie, and responds with redirect +# 1) accepts GET requests on /login and /ldaplogin and responds with a login form +# 2) accepts POST requests on /login and /ldaplogin, sets a cookie, and responds with redirect import sys, os, signal, base64, cgi if sys.version_info.major == 2: @@ -43,8 +43,11 @@ class AppHandler(BaseHTTPRequestHandler): url = urlparse(self.path) - if url.path.startswith("/login") or url.path.startswith("/ldaplogin"): - return self.auth_form() + # set the proper login page subfolder and serve form + if url.path.startswith("/login"): + return self.auth_form(loginsubfolder="/login") + if url.path.startswith("/ldaplogin"): + return self.auth_form(loginsubfolder="/ldaplogin") self.send_response(200) self.end_headers() @@ -52,7 +55,7 @@ class AppHandler(BaseHTTPRequestHandler): # send login form html - def auth_form(self, target = None): + def auth_form(self, target = None, loginsubfolder = ""): # try to get target location from header if target == None: @@ -88,7 +91,7 @@ class AppHandler(BaseHTTPRequestHandler):

Log in to your account

-
+

@@ -109,6 +112,7 @@ class AppHandler(BaseHTTPRequestHandler): self.send_response(200) self.end_headers() self.wfile.write(ensure_bytes(html.replace('TARGET', target))) + self.wfile.write(ensure_bytes(html.replace('LOGINSUBFOLDER', loginsubfolder))) # processes posted form and sets the cookie with login/password