Commit 0d9e8e97 authored by A. Koch's avatar A. Koch

update generic api module, update acl check

parent 2e64ba8c
......@@ -182,9 +182,9 @@
"integrity": "sha512-A2TAGbTFdBw9azHbpVd+/FkdW2T6msN1uct1O9bH3vTerEHKZhTXJUQXy+hNq1B0RagfU8U+KBdqiZpxjhOUQA=="
},
"@types/node": {
"version": "10.3.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.1.tgz",
"integrity": "sha512-IsX9aDHDzJohkm3VCDB8tkzl5RQ34E/PFA29TQk6uDGb7Oc869ZBtmdKVDBzY3+h9GnXB8ssrRXEPVZrlIOPOw=="
"version": "10.5.8",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.8.tgz",
"integrity": "sha512-sWSjw+bYW/2W+1V3m8tVsm9PKJcxk3NHN7oRqNUfEdofKg0Imbdu1dQbFvLKjZQXEDXRN6IfSMACjJ7Wv4NGCQ=="
},
"@types/range-parser": {
"version": "1.2.2",
......@@ -232,14 +232,6 @@
"redis": "^2.2.5"
},
"dependencies": {
"async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
"requires": {
"lodash": "^4.17.10"
}
},
"mongodb": {
"version": "2.2.36",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-2.2.36.tgz",
......@@ -250,15 +242,6 @@
"readable-stream": "2.2.7"
}
},
"mongodb-core": {
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
"integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
"requires": {
"bson": "~1.0.4",
"require_optional": "~1.0.0"
}
},
"process-nextick-args": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz",
......@@ -405,6 +388,14 @@
"resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU="
},
"async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
"requires": {
"lodash": "^4.17.10"
}
},
"asyncemit": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/asyncemit/-/asyncemit-3.0.1.tgz",
......@@ -616,9 +607,9 @@
}
},
"bson": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.6.tgz",
"integrity": "sha512-D8zmlb46xfuK2gGvKmUjIklQEouN2nQ0LEHHeZ/NoHM2LDiMk2EYzZ5Ntw/Urk+bgMDosOZxaRzXxvhI5TcAVQ=="
"version": "1.0.9",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz",
"integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg=="
},
"buffer-crc32": {
"version": "0.2.13",
......@@ -1056,9 +1047,9 @@
"integrity": "sha512-+jpGxSWG4vr6gVxUHOc4p+ilPnql7NzZxOZBxNldsKGjCF+97df3CbuX7XMaDa5oAVkKQj4rKp38rYdC4VcpDg=="
},
"error-ex": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
"integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=",
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
"integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==",
"dev": true,
"requires": {
"is-arrayish": "^0.2.1"
......@@ -1170,9 +1161,9 @@
}
},
"eslint-plugin-import": {
"version": "2.12.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.12.0.tgz",
"integrity": "sha1-2tMXgSktZmSyUxf9BJ0uKy8CIF0=",
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz",
"integrity": "sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g==",
"dev": true,
"requires": {
"contains-path": "^0.1.0",
......@@ -1601,9 +1592,9 @@
"dev": true
},
"hosted-git-info": {
"version": "2.6.0",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz",
"integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==",
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz",
"integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==",
"dev": true
},
"http-errors": {
......@@ -2203,9 +2194,9 @@
}
},
"mbjs-generic-api": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/mbjs-generic-api/-/mbjs-generic-api-0.0.5.tgz",
"integrity": "sha512-wIfOjQk714YUdEpf4xrE6q6ivtMX03NjON1vEfWmbqxV+BkxLy94lBU5z2fl2uMs0AxMKeksA5dorNHX6sqAqA==",
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/mbjs-generic-api/-/mbjs-generic-api-0.0.6.tgz",
"integrity": "sha512-CGSKVHS6lhquSoZ+bmzIytwwYeC+jTH1LieC9595/luOcJ6gM7U6S8/02c8LdITcS9AI074XQxqWc4e4t3GZxA==",
"requires": {
"@polka/send-type": "^0.4.0",
"acl": "^0.4.11",
......@@ -2236,14 +2227,6 @@
"uuid": "^3.2.1",
"validator": "^9.4.1"
}
},
"mongodb": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.1.tgz",
"integrity": "sha512-GU9oWK4pi8PC7NyGiwjFMwZyMqwGWoMEMvM0LZh7UKW/FFAqgmZKjjriD+5MEOCDUJE2dtHX93/K5UtDxO0otg==",
"requires": {
"mongodb-core": "3.1.0"
}
}
}
},
......@@ -2373,21 +2356,37 @@
}
},
"mongodb": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.0.tgz",
"integrity": "sha512-fSDZRq9FomRqeDSM7MpMTLa8sz+STs3nZ7Ib0+xvmaKZ6nquNDN4zGDsVhjto6UozFvHMDYJMAfJwhqUygXs9g==",
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.1.3.tgz",
"integrity": "sha512-hfzI54/fe+604w5gP+i9aJ5GGVxnquxZ09ZN1cyLTbpnBfDRpj78lN59SBdDRkF1VNTzmM2KcgDWhHHDHcsJxw==",
"requires": {
"mongodb-core": "3.1.0"
"mongodb-core": "3.1.2"
},
"dependencies": {
"bson": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/bson/-/bson-1.1.0.tgz",
"integrity": "sha512-9Aeai9TacfNtWXOYarkFJRW2CWo+dRon+fuLZYJmvLV3+MiUp0bEI6IAZfXEIg7/Pl/7IWlLaDnhzTsD81etQA=="
},
"mongodb-core": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.2.tgz",
"integrity": "sha512-R2XxGzsmhlUeOK2jKATj1TWn3q3qNcJpKrSh0rhaBSHxJmV7WZ+ikjocdY8VdJxUkKqOxM8rxMqOAEzeJ3p1ww==",
"requires": {
"bson": "^1.1.0",
"require_optional": "^1.0.1",
"saslprep": "^1.0.0"
}
}
}
},
"mongodb-core": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-3.1.0.tgz",
"integrity": "sha512-qRjG62Fu//CZhkgn0jA/k8jh5MhACIq8cOJUryH6sck87pgt+C222MSD02tsCq5zNo/B6ZFHtNodZ2qpf8E86g==",
"version": "2.1.20",
"resolved": "https://registry.npmjs.org/mongodb-core/-/mongodb-core-2.1.20.tgz",
"integrity": "sha512-IN57CX5/Q1bhDq6ShAR6gIv4koFsZP7L8WOK1S0lR0pVDQaScffSMV5jxubLsmZ7J+UdqmykKw4r9hG3XQEGgQ==",
"requires": {
"bson": "~1.0.4",
"require_optional": "^1.0.1",
"saslprep": "^1.0.0"
"require_optional": "~1.0.0"
}
},
"morgan": {
......@@ -2573,9 +2572,9 @@
"dev": true
},
"p-limit": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.2.0.tgz",
"integrity": "sha512-Y/OtIaXtUPr4/YpMv1pCL5L5ed0rumAaAeBSj12F+bSlMdys7i8oQF/GUJmfpTS/QoaRrS/k6pma29haJpsMng==",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz",
"integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==",
"dev": true,
"requires": {
"p-try": "^1.0.0"
......@@ -2977,9 +2976,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"saslprep": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.0.tgz",
"integrity": "sha512-5lvKUEQ7lAN5/vPl5d3k8FQeDbEamu9kizfATfLLWV5h6Mkh1xcieR1FSsJkcSRUk49lF2tAW8gzXWVwtwZVhw==",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.1.tgz",
"integrity": "sha512-ntN6SbE3hRqd45PKKadRPgA+xHPWg5lPSj2JWJdJvjTwXDDfkPVtXWvP8jJojvnm+rAsZ2b299C5NwZqq818EA==",
"optional": true
},
"schema-object": {
......@@ -3467,9 +3466,9 @@
"integrity": "sha1-8BZSoLS7lByxi7emJI14D9AVAkU="
},
"validate-npm-package-license": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz",
"integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==",
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
"integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==",
"dev": true,
"requires": {
"spdx-correct": "^3.0.0",
......@@ -3524,16 +3523,6 @@
"stack-trace": "0.0.x",
"triple-beam": "^1.3.0",
"winston-transport": "^4.2.0"
},
"dependencies": {
"async": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
"requires": {
"lodash": "^4.17.10"
}
}
}
},
"winston-transport": {
......
......@@ -32,10 +32,10 @@ class Service extends TinyEmitter {
const items = []
for (let entry of results) {
let allowed = false
if (entry.author && entry.author.id === user) allowed = true
if (req.user && entry.author && entry.author.id === user) allowed = true
else {
try {
allowed = await this._acl.isAllowed(user, entry.uuid, 'get')
allowed = await this._acl.isAllowed('public', entry.uuid, 'get')
}
catch (err) {
this._logger.error(`ACL error: ${err.message}`)
......@@ -48,13 +48,12 @@ class Service extends TinyEmitter {
async getHandler (req, res) {
const result = await this.client.get(req.params.id, req.params)
const user = req.user ? req.user.uuid : 'anon'
if (result) {
let allowed = false
if (result.author && result.author.id === user) allowed = true
if (req.user && result.author && result.author.id === req.user.uuid) allowed = true
else {
try {
allowed = await this._acl.isAllowed(user, result.uuid, 'get')
allowed = await this._acl.isAllowed('public', result.uuid, 'get')
}
catch (err) {
this._logger.error(`ACL error: ${err.message}`)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment