I get "permission denied" when I try to create a topic and add two users

60 views
Skip to first unread message

Aleksandr Prazdnikov

unread,
Mar 20, 2022, 9:56:50 AM3/20/22
to Tinode General
Hello!

I use rest authentification. When authorizing the root user, my server returned:

rec={authLvl=root, features=V, tags=[a16227a9-d05a-418b-9cbe-8b0afd13499a]}, newAcc={auth=JRWPA, anon=N, publicFields={fn=admin, userId=a16227a9-d05a-418b-9cbe-8b0afd13499a, photo=null}, privateFields={userId=a16227a9-d05a-418b-9cbe-8b0afd13499a}}

but I get "permission denied" when I try to create a topic and add two users:

out
"
login {
  id: "ecaf3932-d1eb-4565-9be2-f00d51640818"
  scheme: "basic"
  secret: "secret"
}
"
in
"
ctrl {
  id: "ecaf3932-d1eb-4565-9be2-f00d51640818"
  code: 200
  text: "ok"
  params {
    key: "authlvl"
    value: "\"root\""
  }
  params {
    key: "expires"
    value: "\"2022-04-03T13:37:54.356Z\""
  }
  params {
    key: "token"
    value: "\"voyQOzwXV9Eyo0liHgABAAEAqeYD6idjjA/h2bs2ZbNtO4vN+Z6lgDGXpgox+8Pwi50=\""
  }
  params {
    key: "user"
    value: "\"usrvoyQOzwXV9E\""
  }
}
"

out
"
sub {
  id: "0465bcee-3bb5-41ca-8a1f-3556bc35cb4c"
  topic: "new0465bcee-3bb5-41ca-8a1f-3556bc35cb4c"
  set_query {
    desc {
      default_acs {
        auth: "JRWPS"
      }
      public: "{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}"
      private: "{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}"
    }
  }
}
"
in
"
ctrl {
  id: "0465bcee-3bb5-41ca-8a1f-3556bc35cb4c"
  topic: "grpglYtINbM9Qw"
  code: 200
  text: "ok"
  params {
    key: "acs"
    value: "{\"want\":\"JRWPASDO\",\"given\":\"JRWPASDO\",\"mode\":\"JRWPASDO\"}"
  }
  params {
    key: "tmpname"
    value: "\"new0465bcee-3bb5-41ca-8a1f-3556bc35cb4c\""
  }
}
"

out
"
set {
  topic: "grpglYtINbM9Qw"
  query {
    sub {
      user_id: "usrVXw3qDngig4"
      mode: "JRWPS"
    }
  }
}
"
in
"
ctrl {
  topic: "grpglYtINbM9Qw"
  code: 403
  text: "permission denied"
}
"

out
"
set {
  topic: "grpglYtINbM9Qw"
  query {
    sub {
      user_id: "usrzXopBRnLApA"
      mode: "JRWPS"
    }
  }
}
"
in
"
ctrl {
  topic: "grpglYtINbM9Qw"
  code: 403
  text: "permission denied"
}
"

What am I doing wrong? How to log in with root rights, create a topic and add other users to it?

Thanks!

Gene

unread,
Mar 20, 2022, 1:36:39 PM3/20/22
to Tinode General
This does not seem to be a valid Tinode {set} message:

set {
  topic: "grpglYtINbM9Qw"
  query {
    sub {
      user_id: "usrVXw3qDngig4"
      mode: "JRWPS"
    }
  }
}

Gene

unread,
Mar 20, 2022, 1:37:41 PM3/20/22
to Tinode General
this too:

sub {
  id: "0465bcee-3bb5-41ca-8a1f-3556bc35cb4c"
  topic: "new0465bcee-3bb5-41ca-8a1f-3556bc35cb4c"
  set_query {

Gene

unread,
Mar 20, 2022, 1:44:32 PM3/20/22
to Tinode General
Take a look at server-side logs. It may have useful information.

Aleksandr Prazdnikov

unread,
Mar 20, 2022, 11:29:41 PM3/20/22
to Tinode General
I forgot to clarify, I'm using the GRPC protocol. Made requests like this:

2022-03-21 10:16:04.850  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "hi {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  user_agent: "ChatsService/Java"
  ver: "0.16.7"
  device_id: "device-test"
  lang: "EN"
  platform: "java"
  background: true
}
"
2022-03-21 10:16:04.852  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  code: 201
  text: "created"
  params {
    key: "build"
    value: "\"mongodb:v0.18.1\""
  }
  params {
    key: "maxFileUploadSize"
    value: "8388608"
  }
  params {
    key: "maxMessageSize"
    value: "262144"
  }
  params {
    key: "maxSubscriberCount"
    value: "128"
  }
  params {
    key: "maxTagCount"
    value: "16"
  }
  params {
    key: "maxTagLength"
    value: "96"
  }
  params {
    key: "minTagLength"
    value: "2"
  }
  params {
    key: "ver"
    value: "\"0.18\""
  }
}
"
2022-03-21 10:16:04.852  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "login {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  scheme: "basic"
  secret: "secret"
}
"
2022-03-21 10:16:04.861  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"

  code: 200
  text: "ok"
  params {
    key: "authlvl"
    value: "\"root\""
  }
  params {
    key: "expires"
    value: "\"2022-04-04T03:16:04.859Z\""
  }
  params {
    key: "token"
    value: "\"voyQOzwXV9H0YkpiHgABAAEAMCghkePWZdA6jnoKPJYoyqHzElIfM4DTcgXqKQzEv0g=\""

  }
  params {
    key: "user"
    value: "\"usrvoyQOzwXV9E\""
  }
}
"
2022-03-21 10:16:04.862  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "sub {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  topic: "new"
  set_query {
    desc {
      default_acs {
        auth: "JRWS"
        anon: "N"

      }
      public: "{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}"
      private: "{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}"
    }
  }
}
"
2022-03-21 10:16:04.872  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  topic: "grpYSN1Xf3z7p4"

  code: 200
  text: "ok"
  params {
    key: "acs"
    value: "{\"want\":\"JRWPASDO\",\"given\":\"JRWPASDO\",\"mode\":\"JRWPASDO\"}"
  }
  params {
    key: "tmpname"
    value: "\"new\""
  }
}
"
2022-03-21 10:16:04.873  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Finished
2022-03-21 10:16:04.874  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "hi {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  user_agent: "ChatsService/Java"
  ver: "0.16.7"
  device_id: "device-test"
  lang: "EN"
  platform: "java"
  background: true
}
"
2022-03-21 10:16:04.875  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  code: 201
  text: "created"
  params {
    key: "build"
    value: "\"mongodb:v0.18.1\""
  }
  params {
    key: "maxFileUploadSize"
    value: "8388608"
  }
  params {
    key: "maxMessageSize"
    value: "262144"
  }
  params {
    key: "maxSubscriberCount"
    value: "128"
  }
  params {
    key: "maxTagCount"
    value: "16"
  }
  params {
    key: "maxTagLength"
    value: "96"
  }
  params {
    key: "minTagLength"
    value: "2"
  }
  params {
    key: "ver"
    value: "\"0.18\""
  }
}
"
2022-03-21 10:16:04.875  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "login {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  scheme: "basic"
  secret: "secret"
}
"
2022-03-21 10:16:04.882  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"

  code: 200
  text: "ok"
  params {
    key: "authlvl"
    value: "\"root\""
  }
  params {
    key: "expires"
    value: "\"2022-04-04T03:16:04.882Z\""
  }
  params {
    key: "token"
    value: "\"voyQOzwXV9H0YkpiHgABAAEAMCghkePWZdA6jnoKPJYoyqHzElIfM4DTcgXqKQzEv0g=\""

  }
  params {
    key: "user"
    value: "\"usrvoyQOzwXV9E\""
  }
}
"
2022-03-21 10:16:04.883  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "get {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"
  query {
    what: "desc"
  }
}
"
2022-03-21 10:16:04.885  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "meta {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"
  desc {
    created_at: 1647832564863
    updated_at: 1647832564863
    acs {
      want: "JRWPASDO"
      given: "JRWPASDO"
    }
    public: "{\"usrVXw3qDngig4\":{\"name\":\"First\",\"role\":\"user\",\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\"},\"usrzXopBRnLApA\":{\"name\":\"Second\",\"role\":\"user\",\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\"}}"
    private: "[{\"Key\":\"usrVXw3qDngig4\",\"Value\":[{\"Key\":\"userId\",\"Value\":\"e722ac52-778d-407a-ae01-37bbad86c011\"},{\"Key\":\"name\",\"Value\":\"First\"},{\"Key\":\"role\",\"Value\":\"user\"}]},{\"Key\":\"usrzXopBRnLApA\",\"Value\":[{\"Key\":\"userId\",\"Value\":\"2074721d-c85d-4480-9d85-57a91660d582\"},{\"Key\":\"name\",\"Value\":\"Second\"},{\"Key\":\"role\",\"Value\":\"user\"}]}]"
  }
}
"
2022-03-21 10:16:04.885  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "set {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"

  query {
    sub {
      user_id: "usrVXw3qDngig4"
      mode: "JRWP"
    }
  }
}
"
2022-03-21 10:16:04.886  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"

  code: 403
  text: "permission denied"
}
"
2022-03-21 10:16:04.886  INFO 195456 --- [nio-8185-exec-1] c.d.chats.tinode.impl.TinodeClientImpl   : Sending message "set {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"

  query {
    sub {
      user_id: "usrzXopBRnLApA"
      mode: "JRWP"
    }
  }
}
"
2022-03-21 10:16:04.887  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "26c2013c-6f03-4849-8a82-9707db131d0f"
  topic: "grpYSN1Xf3z7p4"

  code: 403
  text: "permission denied"
}
"
2022-03-21 10:16:04.887  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Finished


Tinode's logs don't answer my question why adding a user is not allowed
I2022/03/21 03:16:04 grpc: session started ucg5ZG43uE4 172.18.0.1:47870 1
I2022/03/21 03:16:04 grpc in: hi:{id:"001f8ced-6573-4d34-a57f-8536e026de33" user_agent:"ChatsService/Java" ver:"0.16.7" device_id:"device-test" lang:"EN" platform:"java" background:true} ucg5ZG43uE4
I2022/03/21 03:16:04 grpc in: login:{id:"001f8ced-6573-4d34-a57f-8536e026de33" scheme:"basic" secret:"secret"} ucg5ZG43uE4
I2022/03/21 03:16:04 grpc in: sub:{id:"001f8ced-6573-4d34-a57f-8536e026de33" topic:"new" set_query:{desc:{default_acs:{auth:"JRWS" anon:"N"} public:"{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}" private:"{\"usrVXw3qDngig4\":{\"userId\":\"e722ac52-778d-407a-ae01-37bbad86c011\",\"name\":\"First\",\"role\":\"user\"},\"usrzXopBRnLApA\":{\"userId\":\"2074721d-c85d-4480-9d85-57a91660d582\",\"name\":\"Second\",\"role\":\"user\"}}"}}} ucg5ZG43uE4
I2022/03/21 03:16:04 grpc: session started dmHdk65oKJM 172.18.0.1:47870 1
I2022/03/21 03:16:04 grpc in: hi:{id:"26c2013c-6f03-4849-8a82-9707db131d0f" user_agent:"ChatsService/Java" ver:"0.16.7" device_id:"device-test" lang:"EN" platform:"java" background:true} dmHdk65oKJM
I2022/03/21 03:16:04 grpc in: login:{id:"26c2013c-6f03-4849-8a82-9707db131d0f" scheme:"basic" secret:"secret"} dmHdk65oKJM
I2022/03/21 03:16:04 grpc in: get:{id:"26c2013c-6f03-4849-8a82-9707db131d0f" topic:"grpYSN1Xf3z7p4" query:{what:"desc"}} dmHdk65oKJM
I2022/03/21 03:16:04 grpc in: set:{id:"26c2013c-6f03-4849-8a82-9707db131d0f" topic:"grpYSN1Xf3z7p4" query:{sub:{user_id:"usrVXw3qDngig4" mode:"JRWP"}}} dmHdk65oKJM
I2022/03/21 03:16:04 grpc in: set:{id:"26c2013c-6f03-4849-8a82-9707db131d0f" topic:"grpYSN1Xf3z7p4" query:{sub:{user_id:"usrzXopBRnLApA" mode:"JRWP"}}} dmHdk65oKJM


New topic is being created
2022-03-21 10:16:04.872  INFO 195456 --- [ault-executor-0] c.d.chats.tinode.impl.TinodeClientImpl   : Got message "ctrl {
  id: "001f8ced-6573-4d34-a57f-8536e026de33"
  topic: "grpYSN1Xf3z7p4"

  code: 200
  text: "ok"
  params {
    key: "acs"
    value: "{\"want\":\"JRWPASDO\",\"given\":\"JRWPASDO\",\"mode\":\"JRWPASDO\"}"
  }
  params {
    key: "tmpname"
    value: "\"new\""
  }
}

But why is the answer

value: "{\"want\":\"JRWPASDO\",\"given\":\"JRWPASDO\",\"mode\":\"JRWPASDO\"}"
If I pass
set_query {
     desc {
       default_acs {
         auth: "JRWS"
         anon: "N"
       }


I looked at examples of requests in a web application

понедельник, 21 марта 2022 г. в 00:44:32 UTC+7, Gene:

Gene S

unread,
Mar 20, 2022, 11:56:56 PM3/20/22
to tinode
You cannot issue {set} without subscribing to topic first.
> --
> You received this message because you are subscribed to the Google Groups "Tinode General" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to tinode+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/tinode/1f41c571-339a-4f9e-8f98-dbd46923e829n%40googlegroups.com.

Gene

unread,
Mar 20, 2022, 11:58:21 PM3/20/22
to Tinode General
See here:

Update topic metadata, delete messages or topic. The requester is generally expected to be subscribed and attached to the topic.


Aleksandr Prazdnikov

unread,
Mar 21, 2022, 5:53:59 AM3/21/22
to Tinode General
Thanks! I realized what I was doing wrong. Before adding a user to a topic, it was necessary to make a request, for example:
"sub {
  id: "9167b8db-02d8-4b6f-87a3-a91ad27e7b13"
  topic: "grpgNfX889ZD0c"
  get_query {
    what: "desc"
  }
}
"

понедельник, 21 марта 2022 г. в 10:58:21 UTC+7, Gene:
Reply all
Reply to author
Forward
0 new messages