Using dcc.Interval trigger invocation of auth_function on set interval
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 135
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I have a dcc.Interval defined in one of my pages and BasicAuth for authentication with an auth_func. After I login, the auth_func is invoked on each interval. Is this behavior expected? If it is, what can I check in the auth_func to skip my credentials checking (avoid db/api call) when it is called in the interval?
auth_func
def authorization_function(username, password):
print("Calling Auth: {}".format(datetime.now()))
if (username == "hello") and (password == "world"):
return True
else:
return False
private_user.py
from dash import html, dcc, register_page, callback, Output, Input
from datetime import datetime
register_page(__name__, path_template="/user/<user_id>/public")
def layout(user_id: str):
return [
html.H1(f"User {user_id} (authenticated only)"),
html.Div("Members-only information"),
html.Div(id="interval-holder"),
dcc.Interval(id="interval-component", interval=3000),
]
@callback(
Output("interval-holder", "children"),
Input("interval-component", "n_intervals"),
)
def interval_update(n_intervals):
return "Now is {}".format(datetime.now())
Output
Calling Auth: 2024-08-04 18:00:29.635157
Calling Auth: 2024-08-04 18:00:32.630609
Calling Auth: 2024-08-04 18:00:35.635867
Calling Auth: 2024-08-04 18:00:38.634269
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the behavior using the authorization_function and private_user.py example with BasicAuth and dcc.Interval. Trace how interval callback requests reach authentication, then establish whether repeated auth calls are expected and document or test the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100