From a921fb6a0fb36c1a6ec86bf04cf3027c1d998a70 Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Fri, 7 May 2021 12:15:30 +0200 Subject: [PATCH] changes --- auth.py | 18 ++++++++++++++---- openapi.yaml | 19 ++++++++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/auth.py b/auth.py index 59e36cc..3c57aaa 100755 --- a/auth.py +++ b/auth.py @@ -30,13 +30,20 @@ class PasswordMismatchException(Exception): UserEntry = namedtuple('UserEntry', ['id', 'login', 'expiry', 'claims']) + JWT_PRIV_KEY = "" -with open('/opt/app/config/authservice.key', 'r') as f: - JWT_PRIV_KEY = f.read() +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 = "" -with open('/opt/app/config/authservice.pub', 'r') as f: - JWT_PUB_KEY = f.read() +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() def getUserEntryFromDB(application: str, login: str): @@ -129,5 +136,8 @@ def generateToken(**args): print("ERROR: generateToken: unspecific exception: {}".format(str(e))) raise werkzeug.exceptions.Unauthorized() +def generateTokenFromEnc(content): + return content + def getPubKey(): return JWT_PUB_KEY diff --git a/openapi.yaml b/openapi.yaml index f153239..047565e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -7,7 +7,7 @@ paths: /auth: post: tags: [ "JWT" ] - summary: Return JWT token + summary: Accept login and password, return JWT token operationId: auth.generateToken requestBody: content: @@ -21,6 +21,23 @@ paths: 'text/plain': schema: type: string + /authe: + post: + tags: [ "JWT" ] + summary: Accept encrypted set of credentials, return JWT token + operationId: auth.generateToken + requestBody: + content: + 'text/plain': + schema: + type: string + responses: + '200': + description: JWT token + content: + 'text/plain': + schema: + type: string /secret: get: tags: [ "JWT" ]