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

cartodb-redis

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cartodb-redis - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

test/carto_metadata.test.js

99

lib/carto_metadata.js

@@ -16,4 +16,14 @@ /**

module.exports = function() {
var redis_pool = new RedisPool(global.environment.redis);
//
// @param redis_opts configuration option for redis.
// recognized members for redis_opts are:
// host -- hostname or IP address defaults to 127.0.0.1
// port -- TCP port number, defaults to 6379
// max -- max elements in pool, defaults to 50
// idleTimeoutMillis -- timeout for idle connections, defaults to 10000
// reapIntervalMillis -- timeout check interval, defaults to 1000
// log -- should activities be logged ? defaults to false
//
module.exports = function(redis_opts) {
var redis_pool = new RedisPool(redis_opts);

@@ -35,2 +45,14 @@

/**
* Get the privacy setting of a table
*
* @param dbname - database name, see getDatabase
* @param tablename - name of the table
* @param callback - gets called with args(err, privacy)
*/
me.getTablePrivacy = function(dbname, tablename, callback) {
var redisKey = _.template(this.table_key, {database_name:dbname, table_name:tablename});
this.retrieve(this.table_metadata_db, redisKey, 'privacy', callback);
},
/**
* Get the database name for this particular subdomain/username

@@ -174,74 +196,5 @@ *

};
me.checkAPIKey = me.checkMapKey;
/**
* Get privacy for cartodb table
*
* @param req - standard req object. Importantly contains table and host information
* @param callback - is the table private or not?
*/
me.authorize= function(req, callback) {
var that = this;
Step(
function(){
that.checkMapKey(req, this);
},
function checkIfInternal(err, check_result){
if (err) throw err;
// if unauthorized continue to check table privacy
if (check_result !== 1) return true;
// authorized by key, login as db owner
var user_params = {};
var auth_user = global.settings.postgres_auth_user;
var auth_pass = global.settings.postgres_auth_pass;
Step(
function getId() {
that.getId(req, this);
},
function(err, user_id) {
if (err) throw err;
user_params['user_id'] = user_id;
var dbuser = _.template(auth_user, user_params);
_.extend(req.params, {dbuser:dbuser});
// skip looking up user_password if postgres_auth_pass
// doesn't contain the "user_password" label
if ( ! auth_pass.match(/\buser_password\b/) ) return null;
that.getDatabasePassword(req, this);
},
function(err, user_password) {
if (err) throw err;
user_params['user_password'] = user_password;
if ( auth_pass ) {
var dbpass = _.template(auth_pass, user_params);
_.extend(req.params, {dbpassword:dbpass});
}
return true;
},
function finish(err) {
callback(err, true); // authorized (or error)
}
);
}
,function getDatabase(err, data){
if (err) throw err;
that.getDatabase(req, this);
},
function getPrivacy(err, data){
if (err) throw err;
var redisKey = _.template(that.table_key, {database_name: data, table_name: req.params.table});
that.retrieve(that.table_metadata_db, redisKey, 'privacy', this);
},
function(err, data){
callback(err, data);
}
);
};
/**
* Get the geometry type for this particular table;

@@ -355,2 +308,2 @@ * @param req - standard req object. Importantly contains table and host information

return me;
}();
}
{
"name": "cartodb-redis",
"version": "0.0.1",
"version": "0.1.0",
"main": "./lib/carto_metadata.js",

@@ -5,0 +5,0 @@ "description": "A Node.js based lib to interact with cartodb redis databases",

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