2
2
''''which python >/dev/null && exec python "$0" "$@" # '''
3
3
4
4
# Copyright (C) 2014-2015 Nginx, Inc.
5
- # Copyright (C) 2018 LinuxServer.io
5
+ # Copyright (C) 2018-2020 LinuxServer.io
6
6
7
7
# Example of an application working on port 9000
8
8
# 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
11
11
12
12
import sys , os , signal , base64 , cgi
13
13
if sys .version_info .major == 2 :
@@ -43,16 +43,19 @@ def do_GET(self):
43
43
44
44
url = urlparse (self .path )
45
45
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" )
48
51
49
52
self .send_response (200 )
50
53
self .end_headers ()
51
54
self .wfile .write (ensure_bytes ('Hello, world! Requested URL: ' + self .path + '\n ' ))
52
55
53
56
54
57
# send login form html
55
- def auth_form (self , target = None ):
58
+ def auth_form (self , target = None , loginsubfolder = "" ):
56
59
57
60
# try to get target location from header
58
61
if target == None :
@@ -88,7 +91,7 @@ def auth_form(self, target = None):
88
91
<div class="log-in">
89
92
<div class="content">
90
93
<h1>Log in to your account</h1>
91
- <form action="/login " method="post">
94
+ <form action="LOGINSUBFOLDER " method="post">
92
95
<p>
93
96
<input type="text" name="username" placeholder="Username" aria-label="Username" />
94
97
</p>
@@ -109,6 +112,7 @@ def auth_form(self, target = None):
109
112
self .send_response (200 )
110
113
self .end_headers ()
111
114
self .wfile .write (ensure_bytes (html .replace ('TARGET' , target )))
115
+ self .wfile .write (ensure_bytes (html .replace ('LOGINSUBFOLDER' , loginsubfolder )))
112
116
113
117
114
118
# processes posted form and sets the cookie with login/password
0 commit comments