Skip to content

Dynamic ticket authenticator: unauthorized user causes crossbario error #244

@BramVader

Description

@BramVader

I made an IWampRpcOperation for the authenticator according to the example. My Invoke-method looks like:

public IWampCancellableInvocation Invoke<TMessage>(IWampRawRpcOperationRouterCallback caller, IWampFormatter<TMessage> formatter, InvocationDetails details, TMessage[] arguments, IDictionary<string, TMessage> argumentsKeywords)
{
    if (arguments.Length >= 3)
    {
        string realm = formatter.Deserialize<string>(arguments[0]);
        string username = formatter.Deserialize<string>(arguments[1]);
        JObject jObject = formatter.Deserialize<JObject>(arguments[2]);
        long session = jObject["session"].Value<long>();
        string ticket = jObject["ticket"].Value<string>();

        if (username == "joe" && ticket == "secret!!!")
        {
            caller.Result(null, new YieldOptions(), new[] { (JToken)"anonymous" });
        }
        else
        {
            // Causes crossbario error:
            throw new WampException(WampErrors.NotAuthorized);

            // Causes crossbario error as well:
            Dictionary<string, object> dummyDetails = new Dictionary<string, object>();
            caller.Error(WampObjectFormatter.Value, dummyDetails, "wamp.error.not_authorized", new object[] { "Unauthorized" });
        }
    }
    else
    {
        Dictionary<string, object> dummyDetails = new Dictionary<string, object>();
        caller.Error(WampObjectFormatter.Value, dummyDetails, "wamp.error.runtime_error", new object[] { "Expected parameters" });
    }
    return null;
}

This causes the following error in the crossbario router:

2018-03-29T22:57:25+0000 [Router         15] Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/autobahn/wamp/websocket.py", line 88, in onMessage
    for msg in self._serializer.unserialize(payload, isBinary):
  File "/usr/local/lib/python3.6/site-packages/autobahn/wamp/serializer.py", line 128, in unserialize
    raise ProtocolError("invalid WAMP message type {0}".format(message_type))
autobahn.wamp.exception.ProtocolError: invalid WAMP message type -404

2018-03-29T22:57:25+0000 [Router         15] Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/autobahn/wamp/websocket.py", line 88, in onMessage
    for msg in self._serializer.unserialize(payload, isBinary):
  File "/usr/local/lib/python3.6/site-packages/autobahn/wamp/serializer.py", line 128, in unserialize
    raise ProtocolError("invalid WAMP message type {0}".format(message_type))
autobahn.wamp.exception.ProtocolError: invalid WAMP message type -404

This messageType -404 refers to the enum-value WampMessageType.Unknown, because WampMethodInfo.cs is about a Dispose-method instead of the expected IWampError<TMessage>.Error-method which has an [WampHandler(WampMessageType.v2Error)]-attribute.

Is this a bug, or am I doing something wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions