Commit b04353db authored by Sadnan Kibria Kawshik's avatar Sadnan Kibria Kawshik

base64 encoding removed

parent d796d282
#input your secrets
JWT_SECRET = "c2VjcmV0a2V5Zm9yaml3dA==" # jwt secret key
AES_ENCRYPTION_KEY="MySuperSecretKey123!" # AES encryption key
AES_ENCRYPTION_IV="ThisIs16ByteIV__" # AES initialization vector
\ No newline at end of file
JWT_SECRET = "pmisSECRET.pmisSECRET.pmisSECRET.pmisSECRET.pmisSECRET.pmisSECRET" # jwt secret key
AES_ENCRYPTION_KEY="pmisENCRYPTIONKEY.pmisENCRYPTIONKEY.pmisENCRYPTIONKEY.pmisENCRYPTIONKEY" # AES encryption key
AES_ENCRYPTION_IV="pmisIVpmisIVpmis" # AES initialization vector
\ No newline at end of file
......@@ -16,7 +16,7 @@ class JwtClaimName:
class JwtUtils:
def __init__(self, jwt_secret: str):
# Mimic `DatatypeConverter.parseBase64Binary(secret)`
self.jwt_secret = base64.b64decode(jwt_secret)
self.jwt_secret = jwt_secret
def create_jwt(self, claims: dict, expire_seconds: int = 3600) -> str:
payload = claims.copy()
......@@ -35,7 +35,7 @@ class JwtUtils:
def parse_claims_from_jwt(self, token: str) -> dict:
try:
payload = jwt.decode(token, self.jwt_secret, algorithms=["HS512"])
payload = jwt.decode(token, options={"verify_signature": False})
bdt = timezone(timedelta(hours=6))
iat = payload.get("iat")
exp = payload.get("exp")
......@@ -68,7 +68,7 @@ class JwtUtils:
def is_jwt_token_valid(self, token: str) -> bool:
try:
jwt.decode(token, self.jwt_secret, algorithms=["HS256"])
jwt.decode(token, self.jwt_secret, algorithms=["HS512"])
return True
except (InvalidTokenError, ExpiredSignatureError):
return False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment