Skip to content

Commit 1b8aa8a

Browse files
authored
Merge pull request #33 from linuxserver/subfolder
fix form action (POST address)
2 parents 63fef09 + a22a61e commit 1b8aa8a

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
206206

207207
## Versions
208208

209+
* **08.09.20:** - Set form action correctly.
209210
* **30.07.20:** - Fix bug related to unset optional `CERTFILE` and `KEYFILE` vars.
210211
* **27.07.20:** - Add support for HTTP over SSL (HTTPS).
211212
* **21.07.20:** - Add support for optional user defined fernet key.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ app_setup_block: |
4343
4444
# changelog
4545
changelogs:
46+
- { date: "08.09.20:", desc: "Set form action correctly." }
4647
- { date: "30.07.20:", desc: "Fix bug related to unset optional `CERTFILE` and `KEYFILE` vars." }
4748
- { date: "27.07.20:", desc: "Add support for HTTP over SSL (HTTPS)." }
4849
- { date: "21.07.20:", desc: "Add support for optional user defined fernet key." }

root/app/ldap-backend-app.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
''''which python >/dev/null && exec python "$0" "$@" # '''
33

44
# Copyright (C) 2014-2015 Nginx, Inc.
5-
# Copyright (C) 2018 LinuxServer.io
5+
# Copyright (C) 2018-2020 LinuxServer.io
66

77
# Example of an application working on port 9000
88
# To interact with nginx-ldap-auth-daemon this application
9-
# 1) accepts GET requests on /login and responds with a login form
10-
# 2) accepts POST requests on /login, sets a cookie, and responds with redirect
9+
# 1) accepts GET requests on /login and /ldaplogin and responds with a login form
10+
# 2) accepts POST requests on /login and /ldaplogin, sets a cookie, and responds with redirect
1111

1212
import sys, os, signal, base64, cgi
1313
if sys.version_info.major == 2:
@@ -43,16 +43,19 @@ def do_GET(self):
4343

4444
url = urlparse(self.path)
4545

46-
if url.path.startswith("/login") or url.path.startswith("/ldaplogin"):
47-
return self.auth_form()
46+
# set the proper login page subfolder and serve form
47+
if url.path.startswith("/login"):
48+
return self.auth_form(loginsubfolder="/login")
49+
if url.path.startswith("/ldaplogin"):
50+
return self.auth_form(loginsubfolder="/ldaplogin")
4851

4952
self.send_response(200)
5053
self.end_headers()
5154
self.wfile.write(ensure_bytes('Hello, world! Requested URL: ' + self.path + '\n'))
5255

5356

5457
# send login form html
55-
def auth_form(self, target = None):
58+
def auth_form(self, target = None, loginsubfolder = ""):
5659

5760
# try to get target location from header
5861
if target == None:
@@ -88,7 +91,7 @@ def auth_form(self, target = None):
8891
<div class="log-in">
8992
<div class="content">
9093
<h1>Log in to your account</h1>
91-
<form action="/login" method="post">
94+
<form action="LOGINSUBFOLDER" method="post">
9295
<p>
9396
<input type="text" name="username" placeholder="Username" aria-label="Username" />
9497
</p>
@@ -109,6 +112,7 @@ def auth_form(self, target = None):
109112
self.send_response(200)
110113
self.end_headers()
111114
self.wfile.write(ensure_bytes(html.replace('TARGET', target)))
115+
self.wfile.write(ensure_bytes(html.replace('LOGINSUBFOLDER', loginsubfolder)))
112116

113117

114118
# processes posted form and sets the cookie with login/password

0 commit comments

Comments
 (0)