-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elements don't display when using authentication in 1.3.0 & 2.0.dev1 #1472
Comments
@dosu any ideas? |
The issue you're experiencing with elements not displaying when using authentication in version 2.0.dev1 could be related to changes in how authentication and data layers interact with the UI rendering process. Here are a few things you might want to check or try:
If these steps don't resolve the issue, it might be helpful to look into any recent changes in the Chainlit codebase related to authentication and UI rendering, as there might be undocumented changes affecting this behavior. |
FOUND IT! @dokterbob #1441 is the culprit. Reverting just this change fixes it. It looks like @wenboown found this issue as well. |
yes, it took me a full day to debug this problem since it is not obvious where to look. Hopefully the team can provide a patch soon. |
@wenboown 100% this was difficult to find. The issue is specifically here. Commenting this out makes Elements work properly again. @dokterbob @willydouhard I'm going to make a PR to revert this. |
I am facing the same issue, gonna revert back to 1.2.0 for now |
Thanks for your courage figuring this out. I think I see the problem already, let me attempt a quick fix. |
I'd like to try for a proper fix rather than re-introducing a significant security issue. ReplicationI just replicated it with this minimal example: from typing import Dict, Optional
import chainlit as cl
@cl.password_auth_callback
def auth_callback(username: str, password: str):
# Fetch the user matching username from your database
# and compare the hashed password with the value stored in the database
if (username, password) == ("admin", "admin"):
return cl.User(
identifier="admin", metadata={"role": "admin", "provider": "credentials"}
)
else:
return None
@cl.on_chat_start
async def start():
text_content = "Hello, this is a text element."
elements = [cl.Text(name="simple_text", content=text_content, display="inline")]
await cl.Message(
content="Check out this text element!",
elements=elements,
).send() Observations
Root causeIt seems that the client is not providing the required Authorization header: Responsible code in frontendTwo places (get and upload). Upload is already supplying the authorization header: chainlit/libs/react-client/src/api/index.tsx Line 208 in 2556985
Getter just uses a
It seems that all elements use Could we simply add the access token to Alternatively, if we migrate to using a cookie for authentication, it would solve a lot of potential security pit falls and we won't need to supply auth headers explicitly. |
@dokterbob Feel free to close my PR if you can fix this without reverting the reason this was added in the 1st place. Once merged please make new releases because besides this issue this release improved lots of other things the community wants but we can't upgrade because of this. |
I'm on it! Thanks for the report! |
This is far as I've gotten today. Test replicates it but |
Maybe we can even fetch stuff in the same way we do elsewhere in the API and get rid of the entire useFetch system? |
How much work would this involve and whether it is on your roadmap for future development already? It might be better to "do it properly" rather than quick patch if you already plan to spend time on migrating to cookie? |
@dokterbob me neither, sorry i can't help on that front |
@dokterbob why don't you merge #1474 and make a 1.3.1 release while you figure this out if it's going to take more than 1 day? The last stable release imo is 1.1.404 which is what my users are on and that release contains this "massive vunerability" that exists since forever. At least a new release would be useable in the meantime. |
In short, I'm reluctant shipping a release knowingly re-introducing a high risk security issue. That doesn't seem to me to be the responsible thing to do. I hope to push a fix out this morning though. In the mean time, you are welcome to just run chainlit from the hotfix branch:
|
@hayescode Are you on Discord? Would love to connect. |
Describe the bug
Since updating version from 2.0.dev0 to 1.3.0 & 2.0.dev1 no elements display when using authentication or authentication+data layer. The elements are successfully persisted, and resuming chats display the elements correctly, but not when the user is actually interacting. They either say "An error has occurred, or loading, or some other error.
I believe this is related to Authentication but I have included examples with the data layer too.
Looking at the diff between these versions I cannot figure it out! @dokterbob @willydouhard any ideas?
Note
Elements do not work when only using authentication (no data layer)
Example 1
Example 1 (Auth Only)
Example 2
The text was updated successfully, but these errors were encountered: