1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-03-17 20:57:54 +02:00

Enable token-based authentication

This commit is contained in:
kaiyou 2017-10-29 15:39:28 +01:00
parent 51c301ec56
commit 8095798a04

View File

@ -35,7 +35,16 @@ def handle_authentication(headers):
server, port = get_server(headers["Auth-Protocol"], True)
user_email = urllib.parse.unquote(headers["Auth-User"])
password = urllib.parse.unquote(headers["Auth-Pass"])
ip = urllib.parse.unquote(headers["Client-Ip"])
user = models.User.query.get(user_email)
for token in user.tokens:
if (token.check_password(password) and
(not token.ip or token.ip == ip)):
return {
"Auth-Status": "OK",
"Auth-Server": server,
"Auth-Port": port
}
if user and user.check_password(password):
return {
"Auth-Status": "OK",