Closed pkuwwt closed 1 year ago
Please provide correct full logs. Your client-side and server-side logs are from different sessions (9 minutes apart). Your client-side log is incomplete.
Also, it seems like you have not created the user usrQVuwC5jz9o4
.
@or-else I updated the log.
I don't known where the usrQVuwC5jz9o4
comes from.
I cannot give you any advice because you did not provide enough information.
also, show the logs from your restauth server.
@or-else rest auth server is just the auth.py and dummy_data.json. There is no detailed logs, just sth like
[01/May/2023 21:49:26] "POST /auth HTTP/1.1" 200
All responses are from dummy_data.json.
I searched the code, and found that usrQVuwC5jz9o4
is the topic name, and QVuwC5jz9o4
is the uid of the user in dummy_data.json.
In the server code init_topic.go:initTopicMe()
,
user, err := store.Users.Get(types.ParseUserId(t.name)
t.name
is the usrQVuwC5jz9o4
, the parsed uid is QVuwC5jz9o4
, and the returned user is nil
.
I guess the server get the uid by /auth
from auth server, and search it it database, which obviously not work.
You are attempting to login as alice
and login fails:
{"login":{"id":"80010","scheme":"basic","secret":"YWxpY2U6YWxpY2UxMjM="}}
{"ctrl":{"id":"80010","code":404,"text":"not found","ts":"2023-05-01T02:37:31.956Z"}}
Then you login as bob
and it works. Then you attempt to subscribe to bob
's me
topic and the topic is not found on the server. You probably misconfigured something. Most likely the server is not creating accounts for your users.
This is your config:
"rest": {
"server_url": "http://demo-auth-server:5000/",
"use_separate_endpoints": true
},
This is the sample config from the readme:
"rest": {
// ServerUrl is the URL of the authentication server to call. The URL must be absolute:
// it must include the scheme, such as http or https, and the host name.
"server_url": "http://127.0.0.1:5000/",
// Authentication server is allowed to create new accounts.
"allow_new_accounts": true,
// Use separate endpoints, i.e. add request name to serverUrl path when making requests:
// http://127.0.0.1:5000/add
"use_separate_endpoints": true
},
Do you see the line "allow_new_accounts": true,
in your config?
You still posted just a half of the client-side log.
There is no detailed logs, just sth like
You have the source code. You can add whatever logs you want.
@or-else My mistake.
There is no error of "not found"
, only "user not found"
triggered by init_topic: failed to load or create topic
.
I have tried allow_new_accounts
, nothing changed.
I guess what happened as follows:
bob
, the chat server requested route /auth
from auth server and got the uid
uid
query user from database. user not found
in function init_topic
.allow_new_accounts
, no extra request was received by auth serveris your issue resolved now?
@or-else No.
If my understanding is correct, then I think the rest auth is problematic.
uid
comes from the rest auth server, then init_topic
function should query user from rest auth server other than local database.I think the rest auth is problematic.
Maybe, but more likely that you are doing something incorrectly. If you think there is a bug, then please please debug it and let me know what you find.
then init_topic function should query user from rest auth server other than local database
That's not how it works. rest-auth
responds with enough information to create a user account
https://github.com/tinode/chat/blob/master/rest-auth/auth.py#L53
@or-else I know the logic now.
If there is no uid
in auth server response, and allow_new_accounts
is enabled, then the auth server works.
If there is a uid
in auth server response, and there is no user record in local database, then auth server does not work.
The users in the external auth server will be copied to the local database and generated a uid
. The uid
will be saved to auth server by /link
endpoint.
So the fix will be: remove all uid in dummy_data.json
.
If you found a bug, please send a pull request. Thanks.
REST Auth Problem
I use the code auth.py and the dummy_data.json as the external rest auth server. The
/auth
request is handled. However, there is aninit_topic
error.Your environment
Server-side
Client-side
index-dev.html
to reproduce the problem, notindex.html
.Steps to reproduce
docker-compose.yml
config.template
auth server
demo-auth-server/requirements.txt
demo-auth-server/Dockerfile
The
demo-auth-server/app.py
anddemo-auth-server/dummy_data.json
are from https://github.com/tinode/chat.Execute by
Expected behaviour
Login with
bob:bob123
at 127.0.0.1:6060.Actual behaviour
error displayed on web
Server-side log
Client-side log
websocket message