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

Sending data to dynamic authorizer #248

Open
jig925 opened this issue May 25, 2021 · 1 comment
Open

Sending data to dynamic authorizer #248

jig925 opened this issue May 25, 2021 · 1 comment
Labels

Comments

@jig925
Copy link

jig925 commented May 25, 2021

Hello,

I want to use a dynamic authorizer. I want to authorize the client based on some information sent by the client in "authextra".
In JS this is how it is done:

    var connection = new autobahn.Connection({
      url: "{{.crossbarUrl}}",
      realm: "{{.crossbarRealm}}",
      authmethods: ["ticket"],
      authid: principal,
      onchallenge: onchallenge,
      authextra: {
                  'orgName': bobs[value].name,
                  'token': bobs[value].Token
               }
    });

Once authenticated, the authorizer then accesses that data like:

    def authorize(self, session, uri, action, options):
        token = session["authextra"]["token"]

I was wondering if it is possible to do the same in the client.Config? This is what I currently have in my go file:

func getNexusClient(address string, realm string) (*client.Client, error) {
	cfg := client.Config{
		Realm: realm,
		HelloDetails: wamp.Dict{
			"authid":      "bobController",
			"authmethods": "wampcra",
		},
		AuthHandlers: map[string]client.AuthFunc{
			"wampcra": clientAuthFunc,
		},
	}
	return client.ConnectNet(context.Background(), address, cfg)
}

Thanks.

@gammazero
Copy link
Owner

Yes. The authorizer will be able to see the items you put in HelloDetails in the session.Details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants