jwe
This commit is contained in:
20
auth.py
20
auth.py
@ -30,13 +30,20 @@ class PasswordMismatchException(Exception):
|
|||||||
|
|
||||||
UserEntry = namedtuple('UserEntry', ['id', 'login', 'expiry', 'claims'])
|
UserEntry = namedtuple('UserEntry', ['id', 'login', 'expiry', 'claims'])
|
||||||
|
|
||||||
|
|
||||||
JWT_PRIV_KEY = ""
|
JWT_PRIV_KEY = ""
|
||||||
with open('/opt/app/config/authservice.key', 'r') as f:
|
try:
|
||||||
JWT_PRIV_KEY = f.read()
|
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 = ""
|
JWT_PUB_KEY = ""
|
||||||
with open('/opt/app/config/authservice.pub', 'r') as f:
|
try:
|
||||||
JWT_PUB_KEY = f.read()
|
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):
|
def getUserEntryFromDB(application: str, login: str):
|
||||||
@ -129,8 +136,9 @@ def generateToken(**args):
|
|||||||
print("ERROR: generateToken: unspecific exception: {}".format(str(e)))
|
print("ERROR: generateToken: unspecific exception: {}".format(str(e)))
|
||||||
raise werkzeug.exceptions.Unauthorized()
|
raise werkzeug.exceptions.Unauthorized()
|
||||||
|
|
||||||
def generateTokenFromEnc(content):
|
def generateTokenFromEnc(**args):
|
||||||
return content
|
cryptContent = args["body"]
|
||||||
|
return str(cryptContent)
|
||||||
|
|
||||||
def getPubKey():
|
def getPubKey():
|
||||||
return JWT_PUB_KEY
|
return JWT_PUB_KEY
|
||||||
|
9
testjwe.py
Normal file
9
testjwe.py
Normal 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)
|
Reference in New Issue
Block a user