Commit 05940a90 authored by ibuler's avatar ibuler

Update authentication

parent ace58ad8
......@@ -4,7 +4,7 @@ DEBUG = True
# NAME = 'luna'
# BIND_HOST = '0.0.0.0'
# LISTEN_PORT = 5000
# JUMPSERVER_ENDPOINT = 'http://localhost:8080'
# JUMPSERVER_ENDPOINT = 'http://localhost:8080/'
# ACCESS_KEY = None
# ACCESS_KEY_ENV = 'LUNA_ACCESS_KEY'
# ACCESS_KEY_STORE = os.path.join(BASE_DIR, 'luna', 'keys', '.access_key')
......
......@@ -23,11 +23,13 @@ def login_required(func=None, login_url=None):
csrf_token = request.cookies.get('csrftoken', '')
if '' in [session_id, csrf_token]:
print(session_id, csrf_token)
return redirect(url)
g.user_service = UserService(endpoint=app.config['JUMPSERVER_ENDPOINT'])
g.user_service.auth_from_session(session_id, csrf_token)
user = g.user_service.is_authenticated()
print(user)
if user:
g.user = user
assets = g.user_service.get_my_assets()
......@@ -37,7 +39,7 @@ def login_required(func=None, login_url=None):
g.assets = assets_dict
return func(*args, **kwargs)
else:
return redirect(login_url)
print('hello')
return wrapper
......
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