This commit is contained in:
2021-05-07 13:28:12 +02:00
parent 309b4c6ba8
commit b44af0658a
2 changed files with 23 additions and 6 deletions

12
auth.py
View File

@ -30,11 +30,18 @@ class PasswordMismatchException(Exception):
UserEntry = namedtuple('UserEntry', ['id', 'login', 'expiry', 'claims'])
JWT_PRIV_KEY = ""
try:
JWT_PRIV_KEY = os.environ["JWT_PRIV_KEY"]
except KeyError:
with open('/opt/app/config/authservice.key', 'r') as f:
JWT_PRIV_KEY = f.read()
JWT_PUB_KEY = ""
try:
JWT_PUB_KEY = os.environ["JWT_PUB_KEY"]
except KeyError:
with open('/opt/app/config/authservice.pub', 'r') as f:
JWT_PUB_KEY = f.read()
@ -129,8 +136,9 @@ def generateToken(**args):
print("ERROR: generateToken: unspecific exception: {}".format(str(e)))
raise werkzeug.exceptions.Unauthorized()
def generateTokenFromEnc(content):
return content
def generateTokenFromEnc(**args):
cryptContent = args["body"]
return str(cryptContent)
def getPubKey():
return JWT_PUB_KEY

9
testjwe.py Normal file
View File

@ -0,0 +1,9 @@
from jose import jwe
JWT_PUB_KEY = os.environ["JWT_PUB_KEY"]
plainText = "BlaBlaBla123"
cryptText = jwe.encrypt(plainText, JWT_PUB_KEY, "A256GCM", "RSA-OAEP")
print(cryptText)