Align auth token to flask version to prevent user-logout
This commit is contained in:
@@ -34,7 +34,7 @@ def get_user_from_token(token, secret_key: str, token_type: str = "access"):
|
||||
)
|
||||
try:
|
||||
payload = jwt.decode(token, secret_key, algorithms=[ALGORITHM])
|
||||
username: str = payload.get("sub")
|
||||
username: str = payload.get("identity", {}).get('u')
|
||||
if username is None:
|
||||
raise credentials_exception
|
||||
if payload.get("type") != token_type:
|
||||
@@ -81,7 +81,7 @@ def token_login(form_data: HTTPBasicCredentials = Depends(HTTPBasic()),
|
||||
api_config=Depends(get_api_config)):
|
||||
|
||||
if verify_auth(api_config, form_data.username, form_data.password):
|
||||
token_data = {'sub': form_data.username}
|
||||
token_data = {'identity': {'u': form_data.username}}
|
||||
access_token = create_token(token_data, api_config.get('jwt_secret_key', 'super-secret'))
|
||||
refresh_token = create_token(token_data, api_config.get('jwt_secret_key', 'super-secret'),
|
||||
token_type="refresh")
|
||||
@@ -101,7 +101,7 @@ def token_refresh(token: str = Depends(oauth2_scheme), api_config=Depends(get_ap
|
||||
# Refresh token
|
||||
u = get_user_from_token(token, api_config.get(
|
||||
'jwt_secret_key', 'super-secret'), 'refresh')
|
||||
token_data = {'sub': u}
|
||||
token_data = {'identity': {'u': u}}
|
||||
access_token = create_token(token_data, api_config.get('jwt_secret_key', 'super-secret'),
|
||||
token_type="access")
|
||||
return {'access_token': access_token}
|
||||
|
@@ -34,8 +34,6 @@ class RPCManager:
|
||||
# Enable local rest api server for cmd line control
|
||||
if config.get('api_server', {}).get('enabled', False):
|
||||
logger.info('Enabling rpc.api_server')
|
||||
# from freqtrade.rpc.api_server import ApiServer
|
||||
# TODO: Remove the above import
|
||||
from freqtrade.rpc.api_server2 import ApiServer
|
||||
|
||||
self.registered_modules.append(ApiServer(self._rpc, config))
|
||||
|
Reference in New Issue
Block a user