How to use the cookie.secret function in cookie

To help you get started, we’ve selected a few cookie 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 nodejitsu / kohai / node_modules / twitter / lib / twitter.js View on Github external
Twitter.prototype.login = function(mount, success) {
	var self = this,
		url = require('url');

	// Save the mount point for use in gatekeeper
	this.options.login_mount = mount = mount || '/twauth';

	// Use secure cookie if forced to https and haven't configured otherwise
	if ( this.options.secure && !this.options.cookie_options.secure )
		this.options.cookie_options.secure = true;
	// Set up the cookie encryption secret if we've been given one
	if ( !cookie.secret && this.options.cookie_secret !== null )
		cookie.secret = this.options.cookie_secret;
	// FIXME: ^ so configs that don't use login() won't work?

	return function handle(req, res, next) {
		var path = url.parse(req.url, true);

		// We only care about requests against the exact mount point
		if ( path.pathname !== mount ) return next();

		// Set the oauth_callback based on this request if we don't have it
		if ( !self.oauth._authorize_callback ) {
			// have to get the entire url because this is an external callback
			// but it's only done once...
			var scheme = (req.socket.secure || self.options.secure) ? 'https://' : 'http://',
				path = url.parse(scheme + req.headers.host + req.url, true);
			self.oauth._authorize_callback = path.href;
github nodejitsu / kohai / node_modules / twitter / lib / twitter.js View on Github external
Twitter.prototype.login = function(mount, success) {
	var self = this,
		url = require('url');

	// Save the mount point for use in gatekeeper
	this.options.login_mount = mount = mount || '/twauth';

	// Use secure cookie if forced to https and haven't configured otherwise
	if ( this.options.secure && !this.options.cookie_options.secure )
		this.options.cookie_options.secure = true;
	// Set up the cookie encryption secret if we've been given one
	if ( !cookie.secret && this.options.cookie_secret !== null )
		cookie.secret = this.options.cookie_secret;
	// FIXME: ^ so configs that don't use login() won't work?

	return function handle(req, res, next) {
		var path = url.parse(req.url, true);

		// We only care about requests against the exact mount point
		if ( path.pathname !== mount ) return next();

		// Set the oauth_callback based on this request if we don't have it
		if ( !self.oauth._authorize_callback ) {
			// have to get the entire url because this is an external callback
			// but it's only done once...
			var scheme = (req.socket.secure || self.options.secure) ? 'https://' : 'http://',
				path = url.parse(scheme + req.headers.host + req.url, true);
			self.oauth._authorize_callback = path.href;
		}