update
This commit is contained in:
parent
122ba38beb
commit
2c9224cfeb
|
@ -25,10 +25,11 @@ def create_token(username: str, stream_key: str, exp: int = settings.JWT_EXP_TIM
|
|||
|
||||
|
||||
def verify(token: str):
|
||||
try:
|
||||
jwt.decode(token, JWT_PUB_KEY, algorithms=["RS256"])
|
||||
except (jwt.exceptions.ExpiredSignatureError, jwt.InvalidTokenError):
|
||||
return False
|
||||
jwt.decode(token, JWT_PUB_KEY, algorithms=["RS256"])
|
||||
# try:
|
||||
# jwt.decode(token, JWT_PUB_KEY, algorithms=["RS256"])
|
||||
# except (jwt.exceptions.ExpiredSignatureError, jwt.InvalidTokenError):
|
||||
# return False
|
||||
|
||||
return True
|
||||
|
||||
|
|
|
@ -32,11 +32,12 @@ def publish_check():
|
|||
stream_key = request.form.get('stream_key')
|
||||
username = request.form.get('name')
|
||||
stream_user = user.search_stream_key(stream_key)[0]
|
||||
if username != stream_user['username'] or jwt.verify(stream_key.encode('utf-8')):
|
||||
if username != stream_user['username']:
|
||||
raise ValueError
|
||||
|
||||
except (IndexError, ValueError):
|
||||
print('vish')
|
||||
return Response('Invalid Stream Key', 401)
|
||||
|
||||
jwt.verify(stream_key.encode('utf-8'))
|
||||
return Response('OK', 200)
|
||||
|
|
Loading…
Reference in New Issue