Add base64 utils.
This commit is contained in:
parent
2e9caf66f9
commit
c918d3ed07
@ -1,6 +1,7 @@
|
||||
import dataclasses
|
||||
import typing as t
|
||||
import msgpack
|
||||
import base64
|
||||
|
||||
from fastapi import status, Query, Depends
|
||||
from pydantic import BaseModel as PyBaseModel
|
||||
@ -53,6 +54,15 @@ def msgpack_decode(content):
|
||||
return msgpack.unpackb(content, raw=False)
|
||||
|
||||
|
||||
def b64encode(value):
|
||||
return base64.urlsafe_b64encode(value).decode("ascii").strip("=")
|
||||
|
||||
|
||||
def b64decode(data):
|
||||
data += "=" * ((4 - len(data) % 4) % 4)
|
||||
return base64.urlsafe_b64decode(data)
|
||||
|
||||
|
||||
PERMISSIONS_READ = [Depends(x) for x in app_settings.API_PERMISSIONS_READ]
|
||||
PERMISSIONS_READWRITE = PERMISSIONS_READ + [Depends(x) for x in app_settings.API_PERMISSIONS_WRITE]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user