Call RPC from component with different role Crossbar.io
<p>I need to call procedure in Crossbar component, with it everything ok. But I have such configuration:</p>

<pre><code>   {
      "name": "somerole",
      "permissions": [
        {
          "uri": "com.example.api.sender",
          "match": "exact",
          "allow": {
            "call": true,
            "register": true,
            "publish": false,
            "subscribe": false
          },
        },
        {
          "uri": "wamp.",
          "match": "prefix",
          "allow": {
            "call": true,
            "register": false,
            "publish": false,
            "subscribe": false
          }
        }
      ]
    }
</code></pre>

<p>But with this configuration I can call build in procedure such as 'wamp.subscription.list' and so on, via HTTP from other service. </p>

<p>I want to disable to call build in procedure via HTTP and call such procedures inside component, how can I implement this?</p>

<p>Configuration of component:</p>

<pre><code>    {
      "type": "class",
      "classname": "backend.api.APISession",
      "realm": "example.com",
      "role": "somerole"
    }
</code></pre>

<p>and transport:</p>

<pre><code>        "call": {
          "type": "caller",
          "realm": "example.com",
          "role": "somerole",
          "options": {
            "debug": true
          }
        },
        "callsigned": {
          "type": "caller",
          "realm": "example.com",
          "role": "somerole",
          "options": {
            "post_body_limit": 8192,
            "timestamp_delta_limit": 10,
            "require_ip": [
              "192.168.1.1/255.255.255.0",
              "127.0.0.1"
            ],
            "require_tls": false
          }
        }
</code></pre>

<p>I found a solution.
Created additional class </p>

<pre><code>class APIBaseSession(ApplicationSession):

    instance = None

    @inlineCallbacks
    def onJoin(self, details):
        if not APIBaseSession.instance:
            APIBaseSession.instance = self
        else:
            raise ValueError("Instance of API base was already set")

    @staticmethod
    @inlineCallbacks
    def wamp_subscription_lookup(topic):
        session_id = yield APIBaseSession.instance.call('wamp.subscription.lookup', topic)
        returnValue(session_id)
</code></pre>

<p>then I just call:</p>

<pre><code>APIBaseSession.wamp_subscription_lookup('some_topic')
</code></pre>

<p>And set configuration of two components with different roles as a result we cannot call build in function via HTTP.</p>

python python-3.x autobahn crossbar