sign all
This commit is contained in:
parent
3782b571af
commit
03c90aedf3
@ -30,6 +30,12 @@ class V6D0AuthAppFactory(AppFactory):
|
|||||||
await ws.send_bytes(nonce)
|
await ws.send_bytes(nonce)
|
||||||
hhandle, hnonce = json.loads(certs.verify(await ws.receive_bytes()))
|
hhandle, hnonce = json.loads(certs.verify(await ws.receive_bytes()))
|
||||||
assert hnonce == nonce.hex()
|
assert hnonce == nonce.hex()
|
||||||
|
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))
|
approved = self.cdb.approve(bytes.fromhex(hhandle))
|
||||||
await ws.send_bytes(approved)
|
await ws.send_bytes(approved)
|
||||||
await ws.close()
|
await ws.close()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
from typing import Literal
|
||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
@ -12,12 +13,13 @@ parser.add_argument('handle', type=str)
|
|||||||
|
|
||||||
|
|
||||||
async def main():
|
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:
|
async with aiohttp.ClientSession() as session:
|
||||||
# noinspection HttpUrlsUsage
|
# noinspection HttpUrlsUsage
|
||||||
async with session.ws_connect(f'http://{host}:{port}/approve') as ws:
|
async with session.ws_connect(f'http://{host}:{port}/approve') as ws:
|
||||||
nonce = await ws.receive_bytes()
|
nonce = await ws.receive_bytes()
|
||||||
await ws.send_bytes(certs.sign(json.dumps([handle.hex(), nonce.hex()]).encode()))
|
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())
|
print((await ws.receive_bytes()).hex())
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user