I have implemented router and a publisher. Client needs to connect to the router using Ticket based authentication. Need the format of sending a token in the onchallange method.
Below is my js code.
var connection = new autobahn.Connection({
url: 'ws://127.0.0.1:26429/',
realm: 'testRealm',
authmethods: ["ticket"],
authid: 'testAuthid',
onchallenge: function () {
// Code to send token in the expected format
}
});
In router side , below are the values which i am trying to authenticate:
private readonly IDictionary<string, string> mUserToTicket =
new Dictionary<string, string>
{
["joe"] = "magic_secret_1"
};
How can i convert ["joe"] = "magic_secret_1" into a token that is expected by the router?
Most of the examples are in python and implements a diffrent kind of authentication.
Please help.
Edited
Below is part of router side authentication used.
public IWampSessionAuthenticator GetSessionAuthenticator
(WampPendingClientDetails details,
IWampSessionAuthenticator transportAuthenticator)
{
HelloDetails helloDetails = details.HelloDetails;
if (helloDetails.AuthenticationMethods?.Contains("ticket") != true)
{
throw new WampAuthenticationException("supports only 'ticket' authentication");
}
string user = helloDetails.AuthenticationId;
string ticket;
if (user == null ||
!mUserToTicket.TryGetValue(user, out ticket))
{
throw new WampAuthenticationException
($"no user with authid '{user}' in user database");
}
return new TicketSessionAuthenticator(user, ticket, mUserToAuthorizer[user]);
}