Hey - how can I display UI elements based on which user logged in using basic auth? One way could be getting username
from
from flask import request
user = request.authorization['username']
However, the UI elements are rendered earlier in the process. Is there a callback I can use when user logs in to add a UI element? Think of it in terms of some admin panel we only want to show to a specific user.
Here’s my code for basic auth:
import dash_auth
def basic_auth(app):
if not check_env_true("DEVELOPMENT"):
try:
credentials = {}
for cred_pair in os.environ["BASIC_AUTH_CREDENTIALS"].split(","):
username, password = cred_pair.split(":")
credentials[username] = password
except KeyError as err:
raise BasicAuthCredentialsError(
"Basic auth credentials must be provided via the " "environment variable BASIC_AUTH_CREDENTIALS"
) from err
dash_auth.BasicAuth(app, credentials)