mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-05 06:09:57 -05:00
Upgrading Sanic. Updating tests and schemas.
This commit is contained in:
parent
0bd5d17b46
commit
b1ed453466
18 changed files with 353 additions and 592 deletions
|
|
@ -4,9 +4,10 @@ from string import ascii_letters
|
|||
|
||||
from sanic import response
|
||||
from sanic.request import Request
|
||||
from sanic_ext import validate
|
||||
from sanic_ext.extensions.openapi import openapi
|
||||
|
||||
from wrolpi.root_api import get_blueprint
|
||||
from wrolpi.schema import validate_doc
|
||||
from .common import generate_pdf, encrypt_otp, decrypt_otp
|
||||
from .schema import EncryptOTPRequest, DecryptOTPRequest
|
||||
|
||||
|
|
@ -14,20 +15,16 @@ bp = get_blueprint('OTP', '/api/otp')
|
|||
|
||||
|
||||
@bp.post('/encrypt_otp')
|
||||
@validate_doc(
|
||||
summary='Encrypt a message with OTP',
|
||||
consumes=EncryptOTPRequest,
|
||||
)
|
||||
@openapi.description('Encrypt a message with OTP.')
|
||||
@validate(EncryptOTPRequest)
|
||||
async def post_encrypt_otp(_: Request, data: dict):
|
||||
data = encrypt_otp(data['otp'], data['plaintext'])
|
||||
return response.json(data)
|
||||
|
||||
|
||||
@bp.post('/decrypt_otp')
|
||||
@validate_doc(
|
||||
summary='Decrypt a message with OTP',
|
||||
consumes=DecryptOTPRequest,
|
||||
)
|
||||
@openapi.description('Decrypt a message with OTP.')
|
||||
@validate(DecryptOTPRequest)
|
||||
async def post_decrypt_otp(_: Request, data: dict):
|
||||
data = decrypt_otp(data['otp'], data['ciphertext'])
|
||||
return response.json(data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue