encrypted reg

This commit is contained in:
AF 2021-12-19 19:20:31 +03:00
parent 668eb581c4
commit de995ec626
4 changed files with 5 additions and 5 deletions

View File

@ -1,4 +1,4 @@
aiohttp
PyNaCl~=1.4.0
git+https://gitea.ongoteam.net/PTV/ptvp35.git
git+https://gitea.ongoteam.net/PTV/v6d0auth.git
git+https://gitea.ongoteam.net/PTV/ptvp35.git@25727aabd7
git+https://gitea.ongoteam.net/PTV/v6d0auth.git@2837d32dd6

View File

@ -39,7 +39,7 @@ class V6D1TokensAppFactory(AppFactory):
token_encrypted = await self.tdb.get(await request.read())
except BadSignatureError:
raise web.HTTPUnauthorized
except json.JSONDecodeError:
except (json.JSONDecodeError, AssertionError):
raise web.HTTPBadRequest
except KeyError:
raise web.HTTPNotFound

View File

@ -7,7 +7,7 @@ from v6d0auth.config import host, port
async def main():
request = certs.sign(json.dumps([input('token_id:'), input('token:')]).encode())
request = certs.encrypt_self(certs.sign(json.dumps([input('token_id:'), input('token:')]).encode()))
async with aiohttp.ClientSession() as session:
# noinspection HttpUrlsUsage
async with session.post(f'http://{host}:{port}/reg', data=request) as response:

View File

@ -32,7 +32,7 @@ class TDB:
await self.db.set(token_id, token)
async def reg(self, request: bytes) -> None:
request = certs.verify(request)
request = certs.verify(certs.receive(request))
token_id, token = json.loads(request)
assert type(token_id) == type(token) == str
await self._reg(token_id, token)