From e9749a150cfe8c0548cb78380aba9ab2e4730984 Mon Sep 17 00:00:00 2001 From: Michaƫl Ball Date: Sat, 5 Dec 2015 12:26:19 +0000 Subject: Support api key authentication --- models/user.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'models/user.py') diff --git a/models/user.py b/models/user.py index f912e43..925df5e 100644 --- a/models/user.py +++ b/models/user.py @@ -1,4 +1,8 @@ -from common.security import pwd_context +import os + +from flask.ext.login import make_secure_token + +from common.security import pwd_context, secret_key class User: @@ -46,7 +50,9 @@ class User: else: hash = pwd_context.encrypt(password) - return hash + api_key = make_secure_token(hash, os.urandom(64), key=secret_key) + + return hash, api_key else: raise ValueError("No user") -- cgit v1.2.3