Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-1680

[python] Handle various string inputs for allowed SASL mechanisms and add docs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • proton-c-0.18.0
    • proton-c-0.19.0
    • python-binding
    • None
    • python --version
      Python 2.7.5

    Description

      Docstring says

      allowed_mechs an optional list of SASL mechanisms to allow if sasl is enabled

      If I follow this and provide a Python list, then I am unable to connect, as follows.

      Modify simple_send.py example, change method on_start to read

      def on_start(self, event):
              conn = event.container.connect(self.url, allowed_mechs=["GSSAPI"])
              event.container.create_sender(conn, "myQ")
      

      Try to connect

      [root@localhost ~]# PN_TRACE_FRM=1 python simple-send2.py -a 127.0.0.1
      Traceback (most recent call last):
        File "simple-send2.py", line 63, in <module>
          Container(Send(opts.address, opts.messages)).run()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 148, in run
          while self.process(): pass
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 174, in process
          self._check_errors()
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 170, in _check_errors
          _compat.raise_(exc, value, tb)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 4081, in dispatch
          ev.dispatch(self.handler)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3990, in dispatch
          result = dispatch(handler, type.method, self)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3870, in dispatch
          return handler.on_unhandled(method, *args)
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 523, in on_unhandled
          if not self._override(event):
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 528, in _override
          return conn and hasattr(conn, '_overrides') and event.dispatch(conn._overrides)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3990, in dispatch
          result = dispatch(handler, type.method, self)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3868, in dispatch
          return m(*args)
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 585, in on_connection_local_open
          self._connect(event.connection, event.reactor)
        File "/usr/lib64/python2.7/site-packages/proton/reactor.py", line 572, in _connect
          sasl.allowed_mechs(self.allowed_mechs)
        File "/usr/lib64/python2.7/site-packages/proton/__init__.py", line 3576, in allowed_mechs
          pn_sasl_allowed_mechs(self._sasl, mechs)
      TypeError: in method 'pn_sasl_allowed_mechs', argument 2 of type 'char const *'
      

      Doing allowed_mechs="GSSAPI" produces the same error.

      What works is allowed_mechs=b"GSSAPI" or allowed_mechs="GSSAPI".encode("utf-8")

      root@localhost ~]# PN_TRACE_FRM=1 python simple-send2.py -a 127.0.0.1
      [0x1033cc0]:  -> SASL
      [0x1033cc0]:  <- SASL
      [0x1033cc0]:0 <- @sasl-mechanisms(64) [sasl-server-mechanisms=@PN_SYMBOL[:GSSAPI]]
      [0x1033cc0]:0 -> @sasl-init(65) [mechanism=:GSSAPI, initial-response=b"`\x82\x02V\x06\x09*\x86H\x86\xf7\x12\x01\x02\x02\x01\x00n\x82\x02E0\x82\x02A\xa0\x03\x02\x01\x05\xa1\x03\x02\x01\x0e\xa2\x07\x03\x05\x00 \x00\x00\x00\xa3\x82\x01Wa\x82\x01S0\x82\x01O\xa0\x03\x02\x01\x05\xa1\x10\x1b\x0eATHENA.MIT.EDU\xa2\x1c0\x1a\xa0\x03\x02\x01\x03\xa1\x130\x11\x1b\x04amqp\x1b\x09localhost\xa3\x82\x01\x160\x82\x01\x12\xa0\x03\x02\x01\x12\xa1\x03\x02\x01\x03\xa2\x82\x01\x04\x04\x82\x01\x00\xdb\x08H\x1b\xdb\x05\xb2\xe6k\x95\x91\x1c\xd81\xa7y\x87%"5\x98\xa7\xf6\xe4\x1a\x8a\xa9\Hn\xe0L\x984\xdc\x9f\xe8,ER\x91.\xad\xdf&\x1b\xb3\x8a:\x18\x96\xe8\\xf7\xdf\x9f E\xdb;\xe2`q?\xb1C\xc0\x8e\xbd\xe9\x9c\xfa\x10*`\x14l\xed\xdf\xdez\xb0\x91\xdaC\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      [0x1033cc0]:0 <- @sasl-challenge(66) [challenge=b"`j\x06\x09*\x86H\x86\xf7\x12\x01\x02\x02\x02\x00o[0Y\xa0\x03\x02\x01\x05\xa1\x03\x02\x01\x0f\xa2M0K\xa0\x03\x02\x01\x12\xa2D\x04B\x8d*\x9c\xc4\x91\x95\x0fc\xd6?|\x1a\x80\xaf\xe6\xb8\x04\xa9\xa4\xc9\xe9\x0f\xef9\x80JbM\xb4\xfb\xd3\x88L\x148ju\x98\x9c\xea\x1b\x1f\xd6\xd2\x97\xbe\x8e\xb4\x9f\xbe\x05\xa4\x04\x8d\x05\x0a\x91\x8e\x96,\x80\xd6\xe1\x9a\x9d\xed"]
      [0x1033cc0]:0 -> @sasl-response(67) [response=b""]
      [0x1033cc0]:0 <- @sasl-challenge(66) [challenge=b"\x05\x04\x01\xff\x00\x0c\x00\x00\x00\x00\x00\x00>A\xa9\xf0\x01\x01\x00\x00\xd0wi\x89m\x11\x88\xf9\xeb\xed[\xc9"]
      [0x1033cc0]:0 -> @sasl-response(67) [response=b"\x05\x04\x00\xff\x00\x0c\x00\x00\x00\x00\x00\x00\x0f\x87Oy\x01\x00\x00\x00\x18}\xbd\xdb\xb0\xbe\xb8\xd7\xe9\xec\x80."]
      [0x1033cc0]:0 <- @sasl-outcome(68) [code=0]
      [0x1033cc0]:  <- AMQP
      [0x1033cc0]:  -> AMQP
      [0x1033cc0]:0 -> @open(16) [container-id="d3ed24ec-b9b9-4e91-bf04-7bf355f7f58b", hostname="127.0.0.1", channel-max=32767]
      [0x1033cc0]:0 -> @begin(17) [next-outgoing-id=0, incoming-window=2147483647, outgoing-window=2147483647]
      [0x1033cc0]:0 -> @attach(18) [name="d3ed24ec-b9b9-4e91-bf04-7bf355f7f58b-myQ", handle=0, role=false, snd-settle-mode=2, rcv-settle-mode=0, source=@source(40) [durable=0, timeout=0, dynamic=false], target=@target(41) [address="myQ", durable=0, timeout=0, dynamic=false], initial-delivery-count=0, max-message-size=0]
      [0x1033cc0]:0 <- @open(16) [container-id="0.0.0.0", max-frame-size=4294967295, channel-max=65535, idle-time-out=30000, offered-capabilities=@PN_SYMBOL[:"sole-connection-for-container", :"DELAYED_DELIVERY", :"SHARED-SUBS", :"ANONYMOUS-RELAY"], properties={:product="apache-activemq-artemis", :version="2.4.0"}]
      [0x1033cc0]:0 <- @begin(17) [remote-channel=0, next-outgoing-id=1, incoming-window=2147483647, outgoing-window=2147483647, handle-max=65535]
      [0x1033cc0]:0 <- @attach(18) [name="d3ed24ec-b9b9-4e91-bf04-7bf355f7f58b-myQ", handle=0, role=true, snd-settle-mode=2, rcv-settle-mode=0, source=@source(40) []]
      [0x1033cc0]:0 <- @detach(22) [handle=0, closed=true, error=@error(29) [condition=:"amqp:internal-error", description="AMQ119032: User: user@ATHENA.MIT.EDU does not have permission='CREATE_ADDRESS' on address myQ"]]
      [0x1033cc0]:0 -> @detach(22) [handle=0, closed=true]
      [0x1033cc0]:0 -> @close(24) []
      [0x1033cc0]:  -> EOS
      [0x1033cc0]:0 <- @close(24) []
      [0x1033cc0]:  <- EOS
      

      Attachments

        Activity

          People

            jross Justin Ross
            jdanek Jiri Daněk
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: