INNER CODE UNIT · Python
get_file
Adamkadaban/CTFs · 1.CTFs/CSAW Red 2020/web/jwt/app.py:54
def get_file(filename):
try:
# try to decode token
token = request.cookies.get('jwt').encode('utf-8')
secret = get_secret('static/secret.txt')
json = jwt.decode(token, secret, algorithms=['HS256'])
except NameError:
# unable to decode token, bad secret
return "401 unauthorized: invalid token", 401
except AttributeError:
# no token set
return "401 unauthorized: no token set", 401
except jwt.exceptions.DecodeError:
# unable to decode token, bad token
return "401 unauthorized: invalid token", 401
# check if we have access for file
if json['filename'] == filename: