Skip to content
Snippets Groups Projects
Commit e9978913 authored by f00wl's avatar f00wl
Browse files

Add TOTP capabilities to Auth

parent 1600c09a
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ import sqlalchemy ...@@ -11,6 +11,7 @@ import sqlalchemy
import datetime import datetime
import json import json
import uuid import uuid
import pyotp
def log(category, value=None, comment=None, user=None, profile=None, def log(category, value=None, comment=None, user=None, profile=None,
...@@ -150,6 +151,14 @@ class Auth(db.Model): ...@@ -150,6 +151,14 @@ class Auth(db.Model):
def check_password(self, password): def check_password(self, password):
return hash.pbkdf2_sha256.verify(password, self.value) return hash.pbkdf2_sha256.verify(password, self.value)
def set_otp_key(self):
self.value = pyotp.random_base32()
def check_totp(self, totp):
Totp = pyotp.TOTP(self.value)
return Totp.verify(totp)
class Service(db.Model): class Service(db.Model):
""" A service is a client application (SP or RP typically). """ A service is a client application (SP or RP typically).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment