Skip to content
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

Request: Do not require 'token' to be set by Provider for OnAuthenticate in Client #596

Open
jjgmckenzie opened this issue May 3, 2023 · 8 comments
Assignees

Comments

@jjgmckenzie
Copy link
Contributor

The problem I am facing
I have a cookie stored in the request headers, which is consumed by my auth. However, in order to make use of the OnAuthenticate hook (And to not get messages like [HocuspocusProvider] An authentication token is required, but you didn’t send one. Try adding a `token` to your HocuspocusProvider configuration. Won’t try again. ) , I need to set token to be non nil. A placeholder token like "please_use_auth" works, but I do not see why it is necessary.

The solution I would like
Allow token to be optional, either by default or through configuration

Alternatives I have considered
Using a placeholder token such as "please_use_auth"

@janthurau
Copy link
Collaborator

thx for the report! We noticed the same for our cloud (where we allow anonymous access if wanted), and are also using notoken as a value for this case. It's on the list, right now the server will just wait for the auth token if you have an authentication hook (onAuthenticate defined).

@DenysPoliarush
Copy link
Collaborator

Hi @janthurau, I don't have an onAuthenticate hook on my server, but I still have this error.

The first loading is ok, but when it reconnects after some timeout, the connection closes and won't open.

Screenshot 2023-05-11 at 18 29 01

I've tried to work around it in many ways described in the documentation but to no avail.

I'm using the latest version of HocuspocusProvider and HocuspocusServer - 2.0.6

Can you suggest something?

Thanks!

@juliankrispel
Copy link

I am passing a token (intentionally) and I'm still getting this message :D

@valstu
Copy link
Collaborator

valstu commented May 16, 2023

I am passing a token (intentionally) and I'm still getting this message :D

Same here

@janthurau
Copy link
Collaborator

janthurau commented May 20, 2023

I cannot reproduce this (@valstu @juliankrispel @DenysPoliarush), if you can provide me with a sandbox / replit I'll have a look right away. Please move to #566 though, this issue here is about something else.

@janthurau janthurau reopened this Jun 28, 2023
@valstu
Copy link
Collaborator

valstu commented Jun 29, 2023

I'm not 100% sure yet but this could be related to thing that React in strict mode will call all the effects twice on initial render (mount, unmount and mount again). I destroyed the connection when unmounting (using useEffect return) as it is supposed to but it seems that there are two websocket connections after that which somehow breaks things. I guess the hocuspocus instance was destroyed but not the websocket, anyways it was a late night while debugging this so some of the facts has disappeared from my brain 😅 But I'll try to see if I can reproduce some sandbox in the coming days.

@AliMamed
Copy link

I am passing a token (intentionally) and I'm still getting this message :D

Same here

@juliankrispel @valstu hi. Have you managed to investigate on this? I am also passing token, but i am receiving these messages. It doesn't looks to me that there are any multiple connections and I am pretty sure that every time I initiate connection i pass the token.

@raineorshine
Copy link
Contributor

@AliMamed It's being tracked in #566. This ticket is for a different issue.

@janthurau janthurau mentioned this issue Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants