This commit is contained in:
AF 2022-12-11 16:27:51 +00:00
parent 3782b571af
commit 03c90aedf3
2 changed files with 13 additions and 5 deletions

View File

@ -30,8 +30,14 @@ class V6D0AuthAppFactory(AppFactory):
await ws.send_bytes(nonce)
hhandle, hnonce = json.loads(certs.verify(await ws.receive_bytes()))
assert hnonce == nonce.hex()
approved = self.cdb.approve(bytes.fromhex(hhandle))
await ws.send_bytes(approved)
if hhandle == 'all':
print('approving all')
for request in self.cdb.handle_mapping.values():
request.approve()
print('approved all')
else:
approved = self.cdb.approve(bytes.fromhex(hhandle))
await ws.send_bytes(approved)
await ws.close()
@routes.get('/approve')

View File

@ -1,6 +1,7 @@
import argparse
import asyncio
import json
from typing import Literal
import aiohttp
@ -12,13 +13,14 @@ parser.add_argument('handle', type=str)
async def main():
handle = bytes.fromhex(args.handle)
handle: bytes | Literal['all'] = 'all' if args.handle == 'all' else bytes.fromhex(args.handle)
async with aiohttp.ClientSession() as session:
# noinspection HttpUrlsUsage
async with session.ws_connect(f'http://{host}:{port}/approve') as ws:
nonce = await ws.receive_bytes()
await ws.send_bytes(certs.sign(json.dumps([handle.hex(), nonce.hex()]).encode()))
print((await ws.receive_bytes()).hex())
await ws.send_bytes(certs.sign(json.dumps(['all' if handle == 'all' else handle.hex(), nonce.hex()]).encode()))
if handle != 'all':
print((await ws.receive_bytes()).hex())
if __name__ == '__main__':