mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
obscure private device provenance
Allow users to choose whether or not to reveal the provenance of the data to consumers. This is intended to help protect data rights to portability and access. If consumers start abusing or discriminating against Nightscout users due to the source of the data, this allows users to conceal this information.
This commit is contained in:
@@ -355,7 +355,7 @@ function configure (app, wares, ctx, env) {
|
||||
res.entries_err = err;
|
||||
return next();
|
||||
});
|
||||
}, format_entries);
|
||||
}, wares.obscure_device, format_entries);
|
||||
|
||||
/**
|
||||
* @module get#/entries/:spec
|
||||
@@ -389,7 +389,7 @@ function configure (app, wares, ctx, env) {
|
||||
prepReqModel(req, req.params.model);
|
||||
query_models(req, res, next);
|
||||
}
|
||||
}, format_entries);
|
||||
}, wares.obscure_device, format_entries);
|
||||
|
||||
/**
|
||||
* @module get#/entries
|
||||
@@ -400,7 +400,7 @@ function configure (app, wares, ctx, env) {
|
||||
* `find[date]`.
|
||||
*
|
||||
*/
|
||||
api.get('/entries', ifModifiedSinceCTX, query_models, format_entries);
|
||||
api.get('/entries', ifModifiedSinceCTX, query_models, wares.obscure_device, format_entries);
|
||||
|
||||
/**
|
||||
* @function echo_query
|
||||
@@ -738,7 +738,7 @@ function configure (app, wares, ctx, env) {
|
||||
* @routed
|
||||
* @response 200 /definitions/Entries
|
||||
*/
|
||||
api.get('/times/:prefix?/:regex?', prep_storage, prep_pattern_field, prep_patterns, prep_patterns, query_models, format_entries);
|
||||
api.get('/times/:prefix?/:regex?', prep_storage, prep_pattern_field, prep_patterns, prep_patterns, query_models, wares.obscure_device, format_entries);
|
||||
|
||||
api.get('/count/:storage/where', prep_storage, count_records, format_results);
|
||||
|
||||
@@ -753,7 +753,7 @@ function configure (app, wares, ctx, env) {
|
||||
/api/v1/slice/entries/dateString/mbg/2015.json
|
||||
```
|
||||
*/
|
||||
api.get('/slice/:storage/:field/:type?/:prefix?/:regex?', prep_storage, prep_pattern_field, prep_patterns, query_models, format_entries);
|
||||
api.get('/slice/:storage/:field/:type?/:prefix?/:regex?', prep_storage, prep_pattern_field, prep_patterns, query_models, wares.obscure_device, format_entries);
|
||||
|
||||
/**
|
||||
* @module post#/entries/preview
|
||||
@@ -765,7 +765,7 @@ function configure (app, wares, ctx, env) {
|
||||
// setting this flag tells insert_entries to not actually store the results
|
||||
req.persist_entries = false;
|
||||
next();
|
||||
}, insert_entries, format_entries);
|
||||
}, insert_entries, wares.obscure_device, format_entries);
|
||||
|
||||
// Protect endpoints with authenticated api.
|
||||
if (app.enabled('api')) {
|
||||
@@ -780,7 +780,7 @@ function configure (app, wares, ctx, env) {
|
||||
// setting this flag tells insert_entries to store the results
|
||||
req.persist_entries = true;
|
||||
next();
|
||||
}, insert_entries, format_entries);
|
||||
}, insert_entries, wares.obscure_device, format_entries);
|
||||
|
||||
/**
|
||||
* @module delete#/entries/:spec
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
var wares = {
|
||||
sendJSONStatus : require('./send-json-status'),
|
||||
bodyParser : require('body-parser'),
|
||||
compression : require('compression')
|
||||
compression : require('compression'),
|
||||
obscureDeviceProvenance: require('./obscure-provenance')
|
||||
};
|
||||
|
||||
function extensions (list) {
|
||||
@@ -26,7 +27,8 @@ function configure (env) {
|
||||
limit: '1Mb'
|
||||
}),
|
||||
compression: wares.compression,
|
||||
extensions: extensions
|
||||
extensions: extensions,
|
||||
obscure_device: wares.obscureDeviceProvenance(env)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
module.exports = function create_device_obscurity (env) {
|
||||
function obscure_device (req, res, next) {
|
||||
if (res.entries && env.settings.obscureDeviceProvenance) {
|
||||
for (var i = 0; i < res.entries.length; i++) {
|
||||
res.entries[i].device = env.settings.obscureDeviceProvenance;
|
||||
}
|
||||
}
|
||||
next( );
|
||||
}
|
||||
return obscure_device;
|
||||
}
|
||||
@@ -70,6 +70,8 @@ function init () {
|
||||
, frameName8: ''
|
||||
, authFailDelay: 5000
|
||||
, adminNotifiesEnabled: true
|
||||
, obscured: ''
|
||||
, obscureDeviceProvenance: ''
|
||||
};
|
||||
|
||||
var secureSettings = [
|
||||
@@ -78,6 +80,8 @@ function init () {
|
||||
, 'developerTeamId'
|
||||
, 'userName'
|
||||
, 'password'
|
||||
, 'obscured'
|
||||
, 'obscureDeviceProvenance'
|
||||
];
|
||||
|
||||
var valueMappers = {
|
||||
@@ -129,6 +133,9 @@ function init () {
|
||||
|
||||
function filteredSettings(settingsObject) {
|
||||
let so = _.cloneDeep(settingsObject);
|
||||
if (so.obscured) {
|
||||
so.enable = _.difference(so.enable, so.obscured);
|
||||
}
|
||||
return filterObj(so, secureSettings);
|
||||
}
|
||||
|
||||
@@ -244,6 +251,7 @@ function init () {
|
||||
|
||||
var enable = getAndPrepare('enable');
|
||||
var disable = getAndPrepare('disable');
|
||||
var obscured = getAndPrepare('obscured');
|
||||
|
||||
settings.alarmTypes = prepareAlarmTypes();
|
||||
|
||||
@@ -266,6 +274,7 @@ function init () {
|
||||
|
||||
//all enabled feature, without any that have been disabled
|
||||
settings.enable = _.difference(enable, disable);
|
||||
settings.obscured = obscured;
|
||||
|
||||
var thresholds = settings.thresholds;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user