Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

connect-concierge

Package Overview
Dependencies
Maintainers
1
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-concierge - npm Package Compare versions

Comparing version 0.1.6 to 0.2.0

config/APP_IDS.coffee

68

libs/connect-concierge.js

@@ -7,3 +7,3 @@

(function() {
var ConnectConcierge, dust, fs, request, utils, _, _isAdmin;
var ConnectConcierge, dust, fs, request, urlencode, utils, _, _isAdmin;

@@ -20,2 +20,4 @@ fs = require('fs');

urlencode = require('urlencode');
_isAdmin = utils.isAdmin;

@@ -27,9 +29,6 @@

ConnectConcierge.prototype.getMiddlewares = function(options) {
return [this.getEnvironment(options), this.resolveTags(options), this.resolveTags(options), this.resolveTemplate(options), this.renderTemplate(options)];
return [this.getEnvironment(options), this.authenticationHandler(options), this.resolveTags(options), this.licenseManagerCall(options), this.resolveTemplate(options), this.renderTemplate(options)];
};
ConnectConcierge.prototype.getEnvironment = function(options) {
if (options == null) {
options = {};
}
ConnectConcierge.prototype.getEnvironment = function() {
return function(req, res, next) {

@@ -172,2 +171,59 @@ var env, envRegex, match;

ConnectConcierge.prototype.authenticationHandler = function() {
return function(req, res, next) {
var VtexIdclientAutCookie, forbidden, loginUriRegexp, match, redirectUrl, returnUrl, unauthorized, urlEncodedAuthCookie, vtexIdCookieRegexp, vtexIdEndpoint;
loginUriRegexp = /admin\/Site\/Login.aspx/;
if (loginUriRegexp.test(req.url) || req.url.indexOf('/admin/Content') === 0 || req.url.indexOf('/admin/Scripts') === 0 || req.url.indexOf('/meta/whoami') === 0) {
return next();
}
returnUrl = urlencode(req.url);
redirectUrl = "/admin/Site/Login.aspx?ReturnUrl=" + returnUrl;
vtexIdCookieRegexp = /.*VtexIdclientAutCookie=([^;]*)/;
match = vtexIdCookieRegexp.exec(req.headers.cookie);
VtexIdclientAutCookie = match[1];
if (VtexIdclientAutCookie == null) {
console.log('redirecting to ', redirectUrl);
res.statusCode = 302;
res.setHeader('Location', redirectUrl);
return res.end();
}
forbidden = function(body) {
console.warn("Forbidden access for auth cookie", VtexIdclientAutCookie, '\n', body);
return res.status(403).render('error', {
error: "Forbidden. Sorry, you can't touch this."
});
};
unauthorized = function(body) {
console.warn("Unauthorized access for auth cookie", VtexIdclientAutCookie, '\n', body);
return res.status(401).render('error', {
error: "Unauthorized. Sorry, could not authenticate you."
});
};
vtexIdEndpoint = "https://vtexid.vtex.com.br/api/vtexid/pub/authenticated/user?authToken=";
urlEncodedAuthCookie = encodeURIComponent(VtexIdclientAutCookie);
return request.get(vtexIdEndpoint + urlEncodedAuthCookie, function(err, response, body) {
var e;
try {
body = JSON.parse(body);
if (body == null) {
res.writeHead(302, {
'Location': redirectUrl
});
return res.end;
}
if (body.user == null) {
return unauthorized(body);
}
if (body.user.indexOf("@vtex.com.br") === -1) {
return forbidden(body);
}
return next();
} catch (_error) {
e = _error;
return next(e);
}
});
};
};
return ConnectConcierge;

@@ -174,0 +230,0 @@

9

package.json
{
"name": "connect-concierge",
"version": "0.1.6",
"version": "0.2.0",
"description": "Connect middlewares for VTEX backoffice app Concierge",
"main": "libs/connect-concierge.js",
"main": "main.js",
"scripts": {

@@ -30,4 +30,7 @@ "test": "mocha --compilers coffee:coffee-script/register --reporter spec test/**"

"underscore": "~1.7.0",
"request": "~2.48.0"
"request": "~2.48.0",
"coffee-script": "~1.8.0",
"urlencode": "~0.2.0"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc