litecord.auth: use TimestampSigner

this fixes all tokens being the same.
This commit is contained in:
Luna 2018-12-04 02:21:49 -03:00
parent 8c4b7a1ac8
commit 7d6aab9a29
3 changed files with 3 additions and 5 deletions

View File

@ -4,7 +4,7 @@ from random import randint
import bcrypt import bcrypt
from asyncpg import UniqueViolationError from asyncpg import UniqueViolationError
from itsdangerous import Signer, BadSignature from itsdangerous import TimestampSigner, BadSignature
from logbook import Logger from logbook import Logger
from quart import request, current_app as app from quart import request, current_app as app
@ -38,7 +38,7 @@ async def raw_token_check(token, db=None):
if not pwd_hash: if not pwd_hash:
raise Unauthorized('User ID not found') raise Unauthorized('User ID not found')
signer = Signer(pwd_hash) signer = TimestampSigner(pwd_hash)
try: try:
signer.unsign(token) signer.unsign(token)

View File

@ -24,7 +24,7 @@ async def check_password(pwd_hash: str, given_password: str) -> bool:
def make_token(user_id, user_pwd_hash) -> str: def make_token(user_id, user_pwd_hash) -> str:
"""Generate a single token for a user.""" """Generate a single token for a user."""
signer = itsdangerous.Signer(user_pwd_hash) signer = itsdangerous.TimestampSigner(user_pwd_hash)
user_id = base64.b64encode(str(user_id).encode()) user_id = base64.b64encode(str(user_id).encode())
return signer.sign(user_id).decode() return signer.sign(user_id).decode()

View File

@ -280,8 +280,6 @@ class GuildMemberList:
# list of strings holding the hash input # list of strings holding the hash input
ovs_i = [] ovs_i = []
print(self.list.overwrites)
for actor_id, overwrite in self.list.overwrites.items(): for actor_id, overwrite in self.list.overwrites.items():
allow, deny = ( allow, deny = (
Permissions(overwrite['allow']), Permissions(overwrite['allow']),