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

How to change the authid #7

Open
Yamakaky opened this issue Aug 10, 2017 · 8 comments
Open

How to change the authid #7

Yamakaky opened this issue Aug 10, 2017 · 8 comments
Labels

Comments

@Yamakaky
Copy link
Contributor

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.

@lajosbencz
Copy link
Owner

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?

@Yamakaky
Copy link
Contributor Author

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.

1 similar comment
@Yamakaky
Copy link
Contributor Author

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.

@oeway
Copy link

oeway commented Dec 22, 2017

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.

@lajosbencz
Copy link
Owner

lajosbencz commented Jan 3, 2018

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

@Yamakaky
Copy link
Contributor Author

Yamakaky commented Jan 3, 2018

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

@lajosbencz
Copy link
Owner

lajosbencz commented Jan 22, 2018

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

@Yamakaky
Copy link
Contributor Author

Yamakaky commented Jan 23, 2018

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()
        })
    }
})()

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

3 participants