Setting up Single Sign-on

You may set up Single sign-on (SSO) to provide users with a seamless experience by providing JWT tokens generated by your authentication for weavy. These tokens should be generated server side in your system. You also need to configure the weavy server with a shared secret to be able to receive the JWT tokens.

Read more about configuring JWT tokens for use with Single sign-on. Configure JWT

SSO using options

You may pass the token to weavy by specifying the jwt option in the client.

<script>
    var weavy = new Weavy({
        jwt: '{server_generated_jwt_token}'
    });
</script>

SSO using function

You may also set the JWT token at any point using the sso() function. The function also returns a promise with the user as data.

<script>
    var weavy = new Weavy();
    weavy.authentication.sso('{server_generated_jwt_token}').then(function (user) {
        console.log("Signed in SSO user", user);
    }).catch(function () {
        console.warn("SSO failed");
    });
</script>

Signing out a user

Signing in another SSO user will automatically sign out the previous user. I you want to sign out the current user, you may use the signOut() function.

<script>
    var weavy = new Weavy();
    weavy.authentication.signOut();
</script>