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
|
||||
else:
|
||||
authorized = request.getUser() == 'admin'
|
||||
if authorized:
|
||||
try: YunoHostLDAP(password=request.getPassword())
|
||||
except YunoHostError: authorized = False
|
||||
|
||||
if not authorized:
|
||||
request.setResponseCode(401, 'Unauthorized')
|
||||
request.setHeader('Access-Control-Allow-Origin', '*')
|
||||
request.setHeader('www-authenticate', 'Basic realm="Restricted Area"')
|
||||
return 'Unauthorized'
|
||||
|
||||
# Sanitize arguments
|
||||
|
|
Loading…
Add table
Reference in a new issue