Ticket-based Authentication

With Ticket-based authentication, the client needs to present the server an authentication "ticket" - some magic value to authenticate itself to the server. It can be user password, authentication token or any other kind of client secret. To use it you need to provide "ticket" in "authmethods", authid and onChallenge callback as wampy instance options.

'use strict';

/**
 * Ticket authentication
 */
wampy = new Wampy('wss://wamp.router.url', {
    realm: 'realm1',
    authid: 'joe',
    authmethods: ['ticket'],
    onChallenge: (method, info) => {
        console.log('Requested challenge with ', method, info);
        return 'joe secret key or password';
    }
});

/**
 * Promise-based ticket authentication
 */
wampy = new Wampy('wss://wamp.router.url', {
    realm: 'realm1',
    authid: 'micky',
    authmethods: ['ticket'],
    onChallenge: (method, info) => {
        return new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log('Requested challenge with ', method, info);
                resolve('micky secret key or password');
            }, 2000);
        });
    }
});

Last updated