How to use the rhea.generate_uuid function in rhea

To help you get started, we’ve selected a few rhea examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EnMasseProject / enmasse / agent / lib / auth_utils.js View on Github external
.catch((error) => {
                        console.error('OpenID Connect  Error', error);
                        response.status(500).end('Authentication failed');
                    }).finally(() => {
                        remove_from_session(request, "openid");
                        remove_from_session(request, "state");
                        remove_from_session(request, "saved_request_url");
                        remove_from_session(request, "saved_redirect_url");
                });
            } else {
                const client = new auth_context.Client({
                    client_id: env.CONSOLE_OAUTH_CLIENT_ID,
                    client_secret: env.CONSOLE_OAUTH_CLIENT_SECRET,
                });

                let state = rhea.generate_uuid();
                let redirect_uri = request.protocol + "://" + request.headers.host + "/authcallback";
                store_in_session(request, "openid", client);
                store_in_session(request, "state", state);
                store_in_session(request, "saved_request_url", request.url);
                store_in_session(request, "saved_redirect_url", redirect_uri);

                const authorization_url = client.authorizationUrl({
                    redirect_uri: redirect_uri,
                    scope: env.CONSOLE_OAUTH_SCOPE,
                    state: state,
                    response_type: 'code'
                });

                // redirect
                response.redirect(authorization_url)
            }
github EnMasseProject / enmasse / agent / lib / auth_utils.js View on Github external
const credentials = {
                        client: {
                            id: env.CONSOLE_OAUTH_CLIENT_ID,
                            secret: env.CONSOLE_OAUTH_CLIENT_SECRET,
                        },
                        auth: {
                            tokenHost: auth_context.issuer,
                            authorizePath: auth_context.authorization_endpoint,
                            tokenPath: auth_context.token_endpoint,
                        },
                        options: {
                            authorizationMethod: 'body'
                        },
                    };

                    let state = rhea.generate_uuid();
                    let oauth2 = oauth2_factory.create(credentials);
                    let redirect_uri = request.protocol + "://" + request.headers.host + "/authcallback";
                    store_in_session(request, "oauth2", oauth2);
                    store_in_session(request, "saved_request_url", request.url);
                    store_in_session(request, "saved_redirect_url", redirect_uri);

                    const authorization_url = oauth2.authorizationCode.authorizeURL({
                        redirect_uri: redirect_uri,
                        scope: env.CONSOLE_OAUTH_SCOPE,
                        state: state
                    });

                    // redirect
                    response.redirect(authorization_url)
                } catch (error) {
                    console.error('Authorization Error', error.message);
github mthirion / microsaga / cards / src / main / amq / node_modules / rhea / examples / direct_server.js View on Github external
container.on('sender_open', function (context) {
    if (context.sender.source.dynamic) {
        var id = container.generate_uuid();
        context.sender.set_source({address:id});
    }
});
github amqp / rhea / examples / direct_server.js View on Github external
container.on('sender_open', function (context) {
    if (context.sender.source.dynamic) {
        var id = container.generate_uuid();
        context.sender.set_source({address:id});
    }
});
github EnMasseProject / enmasse / agent / lib / auth_utils.js View on Github external
function init_session(sessions, request, response) {
    let id = get_cookies(request)[SESSION_ID];
    if (id === undefined || sessions[id] === undefined) {
        id = rhea.generate_uuid();
        sessions[id] = {};
        set_cookie(response, SESSION_ID, id);
        log.info('created session: %s', id);
    }
    request.session = sessions[id];
    touch_session(request.session);
    return request.session;
}
github EnMasseProject / enmasse / agent / lib / utils.js View on Github external
module.exports.kubernetes_name = function (name) {
    var clean = name.toLowerCase().replace(/[^a-z0-9\-\.]/g, '');
    if (clean.length > MAX_KUBE_NAME) clean = clean.substring(0, MAX_KUBE_NAME);
    if (clean.charAt(0) === '-' || clean.charAt(0) === '.') clean = clean.substring(1);
    if (clean.charAt(clean.length-1) === '-' || clean.charAt(clean.length-1) === '.') clean = clean.substring(0,clean.length-1);

    var qualifier = rhea.generate_uuid();
    clean += '.' + qualifier;
    return clean;
}
github EnMasseProject / enmasse / agent / lib / ragent.js View on Github external
Ragent.prototype.add_client = function (context) {
    var id = amqp.generate_uuid();
    context.sender.set_source({address:id});
    this.clients[context.connection.container_id] = context.sender;
}