You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
764 B
27 lines
764 B
from datetime import datetime,timedelta
|
|
from uuid import uuid1
|
|
import secrets
|
|
|
|
class Nounce(object):
|
|
def __init__(self):
|
|
self.id = uuid1()
|
|
self.expiration = datetime.now()+timedelta(seconds=60)
|
|
self.token = secrets.token_urlsafe()
|
|
|
|
def expired(self):
|
|
return datetime.now() > self.expiration
|
|
|
|
def bump(self):
|
|
self.expiration = datetime.now()+timedelta(seconds=60)
|
|
|
|
class AuthSession(object):
|
|
def __init__(self, username):
|
|
self.id = uuid1()
|
|
self.expiration = datetime.now()+timedelta(minutes=30)
|
|
self.username = username
|
|
|
|
def expired(self):
|
|
return datetime.now() > self.expiration
|
|
|
|
def bumpExpiration(self):
|
|
self.expiration = datetime.now()+timedelta(minutes=30) |