mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Add HTTP auth password prompt
This commit is contained in:
parent
88dfbfc97f
commit
b0dd6a2b2a
1 changed files with 4 additions and 2 deletions
|
@ -36,12 +36,14 @@ def http_exec(request):
|
||||||
# Simple HTTP auth
|
# Simple HTTP auth
|
||||||
else:
|
else:
|
||||||
authorized = request.getUser() == 'admin'
|
authorized = request.getUser() == 'admin'
|
||||||
try: YunoHostLDAP(password=request.getPassword())
|
if authorized:
|
||||||
except YunoHostError: authorized = False
|
try: YunoHostLDAP(password=request.getPassword())
|
||||||
|
except YunoHostError: authorized = False
|
||||||
|
|
||||||
if not authorized:
|
if not authorized:
|
||||||
request.setResponseCode(401, 'Unauthorized')
|
request.setResponseCode(401, 'Unauthorized')
|
||||||
request.setHeader('Access-Control-Allow-Origin', '*')
|
request.setHeader('Access-Control-Allow-Origin', '*')
|
||||||
|
request.setHeader('www-authenticate', 'Basic realm="Restricted Area"')
|
||||||
return 'Unauthorized'
|
return 'Unauthorized'
|
||||||
|
|
||||||
# Sanitize arguments
|
# Sanitize arguments
|
||||||
|
|
Loading…
Add table
Reference in a new issue