【问题标题】:User authorization failed xmpp in ejabberdejabberd 中的用户授权失败 xmpp
【发布时间】:2020-06-22 03:59:38
【问题描述】:

我已经在 ejabberd 中注册了我的管理员用户。当我尝试使用 xmpp php 代码在 ejabberd 中注册新用户时,我收到一个错误 xmlrpc: Error -118 A problem '{error,access_rules_unauthorized}' occurred executing the command register with arguments。我尝试了很多事情,但无法得到任何解决方案,并且一次又一次地遇到相同的错误。

【问题讨论】:

    标签: xmpp ejabberd


    【解决方案1】:

    是的,为这些 API 前端正确配置权限并获得正确传递给它们的身份验证详细信息可能会很棘手。

    使用这样的配置:

    listen:
      ...
      -
        port: 4560
        module: ejabberd_xmlrpc
    
    acl:
      admin:
        user:
          - user1@localhost
    
    api_permissions:
      "register command":
        from: ejabberd_xmlrpc
        who:
          access:
            allow:
              acl: admin
        what: register
    

    并使用那个 Python 客户端:

    import xmlrpclib
    
    server_url = 'http://127.0.0.1:4560'
    server = xmlrpclib.ServerProxy(server_url)
    
    EJABBERD_XMLRPC_LOGIN = {'user':'user1', 'server':'localhost', 'password':'mypass11', 'admin':True}
    
    def ejabberdctl(command, data):
        fn = getattr(server, command)
        return fn(EJABBERD_XMLRPC_LOGIN, data)
    
    print ""
    print "Calling with auth details..."
    result = ejabberdctl('register', {'user':'User5', 'host':'localhost', 'password':'newpass'})
    print "Results: "
    print result
    

    记得使用该密码注册 user1,或根据您的管理员帐户修改该脚本。

    然后执行它,应该可以正常工作了:

    $ python test.py 
    
    Calling with auth details...
    Results: 
    {'res': 0, 'text': 'User User5@localhost successfully registered'}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-25
      • 2014-02-06
      • 2022-11-30
      • 1970-01-01
      • 2018-08-25
      • 2018-03-12
      • 2018-12-22
      • 1970-01-01
      相关资源
      最近更新 更多