Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic authenticator example #141

Open
xhh opened this issue Sep 22, 2016 · 2 comments
Open

Dynamic authenticator example #141

xhh opened this issue Sep 22, 2016 · 2 comments

Comments

@xhh
Copy link

xhh commented Sep 22, 2016

As described in Corssbar WAMP-CRA dynamic authentication docs:

The return value must be a dictionary with two mandatory attributes:

  • secret: The secret shared with the client (possibly after salting)
  • role: The authrole to assign to the client if successfully authenticated

The authentication procedure I registered is defined as this (the result is a std::map):

void authenticate(autobahn::wamp_invocation invocation) {
  auto authid = invocation->argument<std::string>(1);
  std::map<std::string, std::string> result {
    { std::string("secret"), std::string("abc") },
    { std::string("role"), std::string("user") }
  };
  invocation->result(result);
}

And I got this error with the client trying to authenticate via the WAMP-CRA authentication:

RX message: abort [{"message":"got invalid return type \"<class 'autobahn.wamp.types.CallResult'>\" from dynamic authenticator"}, "wamp.error.authentication_failed"]

How shall I return the secret and role in the authenticate procedure here? Can't find any example code, please allow me asking here.

@fin-ger
Copy link

fin-ger commented Mar 20, 2017

I figured out that you have to return a std::tuple of a std::map:

std::map<std::string, std::string> result;
result["secret"] = secret;
result["role"] = role;
result["salt"] = salt;
invocation->result (std::make_tuple (result));

@oberstet
Copy link
Contributor

Yeah, a dynamic authenticator is supposed to return a single positional value (hence the tuple of length 1), and that value needs to be a map. Sorry for leaving you in the rain and guessing ..

We should add an example. We have one for authenticating a client (https://github.com/crossbario/autobahn-cpp/blob/master/examples/wampcra.cpp), but we don't have one for a dynamic authenticator in C++

@oberstet oberstet changed the title Guest component providing dynamic WAMP-CRA authentication procedure Dynamic authenticator example Mar 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants