crossbario / crossbar

Crossbar.io - WAMP application router
https://crossbar.io/
Other
2.05k stars 274 forks source link

Authentication using method 'wampcra' denied by configuration #153

Closed fr34kyn01535 closed 9 years ago

fr34kyn01535 commented 10 years ago

I tried to setup authentication on a nodejs in crossbar with a javascript frontend and get: WebSocket transport send [1,"MyApp",{"roles":{"caller":{"features":{"caller_identification":true,"progressive_call_results":true}},"callee":{"features":{"progressive_call_results":true}},"publisher":{"features":{"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"publisher_identification":true}},"subscriber":{"features":{"publisher_identification":true}}},"authmethods":["wampcra"],"authid":"Tester"}] autobahn-0.9.5.min.js:33 WebSocket transport receive [3,{"message":"authentication using method 'wampcra' denied by configuration"},"wamp.error.not_authorized"]

My clientcode:

connection = new autobahn.Connection({
    url: 'ws://' + hostname + ':9000/ws/',
    realm: 'MyApp',
    authmethods: ["wampcra"],
    authid: 'Tester',
    onchallenge: function(session, method, extra){
        return autobahn.auth_cra.sign("test", extra.challenge);
    }
});

My config.json

...
  "ws": {
     "type": "websocket",
      "cookie": {
          "name": "MyApp",
          "length": 16,
          "max_age": 86400
      },
      "auth": {
          "wampcra": {
              "type": "dynamic",
              "authenticator": "com.test.myapp.server.authenticate"
          }
      }
  }

My server code:

...
connection.onopen = function (session) {
        try {
            // Actions
            session.register('com.test.myapp.server.authenticate', function(realm, authid) {
    return {'secret': 'test', 'role': 'registered'};
});

...

In the console i can read:

2014-11-08 16:22:59+0100 [Router      20507] XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX HelloDetails(roles = [<autobahn.wamp.role.RoleSubscriberFeatures inst
ance at 0x7fdbf2508e18>, <autobahn.wamp.role.RolePublisherFeatures instance at 0x7fdbf2508f80>, <autobahn.wamp.role.RoleCallerFeatures instance at 0x7fdbf2508fc8>, <autobahn.wamp.role.RoleCalleeFeatures instance at 0x7fdbf250c050>], authmethods = [u'wampcra'], authid = Tester, pending_session = 3976544598800198) {u'authenticator': u'com.test.myapp.server.authenticate', u'type': u'dynamic'}
oberstet commented 9 years ago

cannot replicate. this works for me: https://github.com/crossbario/crossbarexamples/tree/master/authenticate