How to use the cookie-parser.signedCookies function in cookie-parser

To help you get started, we’ve selected a few cookie-parser 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 pmlrsg / GISportal / app / lib / collaboration.js View on Github external
io.set('authorization', function (handshakeData, accept) {
      // check if there's a cookie header
      if (handshakeData.headers.cookie) {
         try {
            var cookies = cookieParser.signedCookies(cookie.parse(handshakeData.headers.cookie), config.session.secret);
            var sid = cookies.GISportal;

            var sessionStore = app.get('sessionStore');
            sessionStore.load(sid, function(err, session) {
               if(err || !session) {
                  return accept('Error retrieving session!', false);
               }
            });

         } catch(e) {
            console.log(e);
         }


      } else {
         // if there isn't, turn down the connection with a message
github qmit-pro / moleculer-api / src / server / application / context / factory / cookie.ts View on Github external
public create({headers}: APIRequestContextSource) {
    if (!headers.cookie) {
      return {};
    }

    const {secrets, ...parseOptions} = this.opts;
    const cookies = parseCookieString(headers.cookie, parseOptions);

    // parse signed cookies
    if (secrets.length !== 0) {
      Object.assign(cookies, signedCookies(cookies, secrets));
    }

    // parse JSON cookies
    return JSONCookies(cookies);
  }
}
github pmlrsg / GISportal / collaboration / index.js View on Github external
io.on('connection', function(socket){

   socket.room = '';
   
	var cookies = cookieParser.signedCookies(cookie.parse(socket.request.headers.cookie), config.session.secret);
   var sid = cookies['collaboration'];

   var user = {};
   var sessionStore = app.get('sessionStore');
	sessionStore.load(sid, function(err, session) {
		if (err || !session) {
         console.log('no passport');
			return 'no passport';
		}

		var emails = session.passport.user.emails;

		user.email = emails[0].value;
		user.name = session.passport.user.displayName;
		user.provider = session.passport.user.provider;
github litixsoft / baboon / lib / session.js View on Github external
pub.getSessionId = function (cookie) {

        if (typeof cookie !== 'string') {
            throw new SessionError('Parameter cookie is required and must be a string type!');
        }

        var signedCookie = cookies.parse(cookie);
        return parseSignedCookie(signedCookie, secret)[key];
    };
github Frost-Dev / Frost-Web / src / server / helpers / get-session-from-cookie.js View on Github external
module.exports = async (cookieString, sessionCookieName, cookieSecret, store) => {
	if (cookieString == null)
		return null;

	let cookies = cookieParser.signedCookies(cookie.parse(cookieString), cookieSecret);
	const session = await prominence(store).get(cookies[sessionCookieName]);

	return session;
};

cookie-parser

Parse HTTP request cookies

MIT
Latest version published 27 days ago

Package Health Score

89 / 100
Full package analysis