vue-wamp icon indicating copy to clipboard operation
vue-wamp copied to clipboard

How to change the authid

Open Yamakaky opened this issue 7 years ago • 8 comments

Currently, it's not possible to change the authid after the VueWamp object creation. Maybe by redoing the Vue.use...?

A cleaner way would be to handle it directly in the plugin.

Yamakaky avatar Aug 10 '17 21:08 Yamakaky

Im not sure you should be able to change that... authid is a response by the router after authentication, clients should not be able to change it.

Is it possible with AutobahnJS to change the authid on demand after successfully connecting?

lajosbencz avatar Sep 26 '17 16:09 lajosbencz

Yeah, you can't change the authid after login. My use case is that I use the authid as username and token challenge as password for a web interface. I manually close the session and reopen a new one.

Yamakaky avatar Sep 26 '17 17:09 Yamakaky

Yeah, you can't change the authid after login. My use case is that I use the authid as username and token challenge as password for a web interface. I manually close the session and reopen a new one.

Yamakaky avatar Sep 26 '17 17:09 Yamakaky

Any news on this issue? I am trying to do something similar. Where I have a login workflow. When the webpage is loaded, it uses a anonymous authentication, then the user try to click a login button to login with authid and password.

So in that case, how to handle the authentication options? I tried to do a reconnect, but having problem with pass the new options and to force autobahn to reconnect.

oeway avatar Dec 22 '17 13:12 oeway

As far as I know, you SHOULD NOT change the authid from the client side. It might not even be possible. Just imagine a hacker changing the authid on demand.

Authid is provided by the registered dynamic authenticators, or the static rules in the config.

Closing this issue as it is unsupported by crossbar

lajosbencz avatar Jan 03 '18 13:01 lajosbencz

You can, if you disconnect then reconnect. An easy way to do that would be handy.

Yamakaky avatar Jan 03 '18 21:01 Yamakaky

@Yamakaky could you paste in a code snippet of your re-auth process?

lajosbencz avatar Jan 22 '18 09:01 lajosbencz

export const reconnect = (() => {
    let connection

    return () => {
        if (connection) {
            // Throws if already closed
            try {
                connection.close("closing_old_connection")
            } catch (e) {
                console.error(e)
            }
        }

        return new window.Promise((resolve, reject) => {
                const url = ...
                const realm = ...
                connection = new autobahn.Connection({
                    url,
                    realm,
                    authmethods: [
                        "cookie",
                    ],
                    authid: username,
                    onchallenge: onchallenge,
                })
                connection.onopen = (...args) => {
                    onopen(...args)
                    resolve()
                }
                connection.onclose = (...args) => {
                    reject()
                    onclose(...args)
                }
                connection.open()
        })
    }
})()

Yamakaky avatar Jan 23 '18 19:01 Yamakaky