Skip to content
Snippets Groups Projects
Commit 14201ae4 authored by ale's avatar ale
Browse files

Add auth.user tracing parameter (server-side)

parent ddc715b8
No related branches found
No related tags found
No related merge requests found
Pipeline #61196 passed
...@@ -13,6 +13,8 @@ from flask import request, session, redirect, make_response, g, \ ...@@ -13,6 +13,8 @@ from flask import request, session, redirect, make_response, g, \
render_template, abort, current_app render_template, abort, current_app
from flask_talisman import ALLOW_FROM from flask_talisman import ALLOW_FROM
from opentelemetry import trace
def init_sso(app, talisman): def init_sso(app, talisman):
if 'SSO_LOGIN_SERVER' not in app.config: if 'SSO_LOGIN_SERVER' not in app.config:
...@@ -142,6 +144,12 @@ def auth_required(unauth_action=_redirect_to_login_server): ...@@ -142,6 +144,12 @@ def auth_required(unauth_action=_redirect_to_login_server):
else: else:
current_app.logger.error('authentication failed: %s', e) current_app.logger.error('authentication failed: %s', e)
return unauth_action() return unauth_action()
# Add authentication info to the current trace, if any.
current_span = trace.get_current_span()
if current_span:
current_span.set_attribute('auth.user', g.current_user)
return func(*args, **kwargs) return func(*args, **kwargs)
return _auth_wrapper return _auth_wrapper
return _auth_required_decorator return _auth_required_decorator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment