0

大家好,我正在使用 ejabberd,我想生成一个不记名令牌来访问所有方法并使用 ejabberd 的 REST 获取数据。当我尝试生成标头中没有身份验证的承载令牌时,它显示一个错误,即在此处输入图像描述

我正在为ejabberd_http模块使用端口 5180 我的配置是

    port: 5180
    ip: "::"
    module: ejabberd_http
    request_handlers:
      /admin: ejabberd_web_admin
      /api: mod_http_api
      /xmlrpc: ejabberd_xmlrpc
      /oauth": ejabberd_oauth

api权限的配置是

oauth_access:
  - allow:
    - user:
      - "admin@localhost"  # add your user name

oauth_expire: 86400


acl:
  local:
    user_regexp: ""
  loopback:
    ip:
      - 127.0.0.0/8
      - ::1/128
      - ::FFFF:127.0.0.1/128
      - ::FFFF:43.250.158.125/16
  admin:
    user:
      - "admin@localhost"
    ip:
      - "::"
      - ::FFFF:43.250.158.125/16

api_permissions:
  "some XMLRPC commands":
    from: ejabberd_xmlrpc
    who:
      - ip:  127.0.0.1
      - user: admin@localhost
    what:
      - "*"
      # - registered_users
      # - register
      # - connected_users_number
      # - change_password
      # - check_password_hash

  "admin access":
    who:
      ip: 127.0.0.1/8
      oauth:
        scope: "ejabberd:admin"
        access:
          allow:
            acl: loopback
            acl: admin
    what:
      - "*"

  "console commands":
    from:
      - ejabberd_ctl
    who: all
    what: "*"


  "loopback access":
    who:
      - ip: "::"
    what:
      - "*"


  "public commands":
    who:
      ip: 127.0.0.1/8
    what:
      - "*"




access_rules:
  register:
    allow: all
  # configure: 
  #   - allow: all

  local:
    # allow
    allow: all
  c2s:
    # deny: blocked
    allow: all
  announce:
    allow: all
  configure:
    allow: all
  muc_create:
    allow: all
  pubsub_createnode:
    allow: local
  trusted_network:
    allow: all

我想使用其余部分将消息发送给用户,但为此我需要不记名令牌,当我尝试生成不记名令牌时显示错误请建议我一些方法来解决此问题并生成不记名令牌

谢谢

4

1 回答 1

0

配置完成后:

oauth_expire: 3600
oauth_access:
  - allow:
    - user:
      - "admin@localhost"  # add your user name

首先尝试使用命令行:

❯ ejabberdctl oauth_issue_token admin@localhost 3600 "registered_users;muc_online_rooms"
yamdcY4TGqltWCprCnunZjrz7ZNSmL8d        [<<"registered_users">>,<<"muc_online_rooms">>] 3600 seconds

一旦成功,您可以尝试使用网络获取令牌,这需要更多配置步骤。

于 2021-12-22T15:42:05.297 回答