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:
parent
51c301ec56
commit
8095798a04
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user