This commit is contained in:
Wolfgang Hottgenroth 2021-05-07 12:15:30 +02:00
parent f56db65012
commit a921fb6a0f
Signed by: wn
GPG Key ID: 6C1E5E531E0D5D7F
2 changed files with 32 additions and 5 deletions

18
auth.py
View File

@ -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

View File

@ -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" ]