1
0
Fork 0

Fix deleting rocksdb views and dump_authentication (#5779)

* fix deleting rocksdb views and dump_authentication

* fix changelog, fix test
This commit is contained in:
Simon 2018-07-05 09:40:43 +02:00 committed by Jan
parent 222f77249f
commit f699d32664
4 changed files with 26 additions and 11 deletions

View File

@ -1,6 +1,9 @@
devel devel
----- -----
* if authentication is turned on requests to databases by users with insufficient rights
will be answered with the HTTP forbidden (401) response.
* upgraded bundled RocksDB library version to 5.14 * upgraded bundled RocksDB library version to 5.14
* added key generators `uuid` and `padded` * added key generators `uuid` and `padded`

View File

@ -136,16 +136,21 @@ bool resolveRequestContext(GeneralRequest& req) {
/// response if execution is supposed to be aborted /// response if execution is supposed to be aborted
GeneralCommTask::RequestFlow GeneralCommTask::prepareExecution( GeneralCommTask::RequestFlow GeneralCommTask::prepareExecution(
GeneralRequest& req) { GeneralRequest& req) {
if (!::resolveRequestContext(req)) { if (!::resolveRequestContext(req)) { // false if db not found
if (_auth->isActive()) { if (_auth->isActive()) {
// prevent guessing of database names (issue #5030) // prevent guessing database names (issue #5030)
addErrorResponse(rest::ResponseCode::UNAUTHORIZED, auth::Level lvl = auth::Level::NONE;
req.contentTypeResponse(), req.messageId(), if (req.authenticated()) {
TRI_ERROR_FORBIDDEN); lvl = _auth->userManager()->databaseAuthLevel(req.user(), req.databaseName());
} else { }
addErrorResponse(rest::ResponseCode::NOT_FOUND, req.contentTypeResponse(), if (lvl == auth::Level::NONE) {
req.messageId(), TRI_ERROR_ARANGO_DATABASE_NOT_FOUND); addErrorResponse(rest::ResponseCode::UNAUTHORIZED, req.contentTypeResponse(),
req.messageId(), TRI_ERROR_FORBIDDEN);
return RequestFlow::Abort;
}
} }
addErrorResponse(rest::ResponseCode::NOT_FOUND, req.contentTypeResponse(),
req.messageId(), TRI_ERROR_ARANGO_DATABASE_NOT_FOUND);
return RequestFlow::Abort; return RequestFlow::Abort;
} }
TRI_ASSERT(req.requestContext() != nullptr); TRI_ASSERT(req.requestContext() != nullptr);

View File

@ -332,7 +332,7 @@ RocksDBKeyBounds RocksDBIndex::getBounds(Index::IndexType type,
return RocksDBKeyBounds::GeoIndex(objectId); return RocksDBKeyBounds::GeoIndex(objectId);
#ifdef USE_IRESEARCH #ifdef USE_IRESEARCH
case RocksDBIndex::TRI_IDX_TYPE_IRESEARCH_LINK: case RocksDBIndex::TRI_IDX_TYPE_IRESEARCH_LINK:
return RocksDBKeyBounds::Empty(); return RocksDBKeyBounds::DatabaseViews(objectId);
#endif #endif
case RocksDBIndex::TRI_IDX_TYPE_UNKNOWN: case RocksDBIndex::TRI_IDX_TYPE_UNKNOWN:
default: default:

View File

@ -495,7 +495,7 @@ function AuthSuite() {
"preferred_username": "root", "preferred_username": "root",
"iss": "arangodb", "exp": Math.floor(Date.now() / 1000) + 3600 "iss": "arangodb", "exp": Math.floor(Date.now() / 1000) + 3600
}, 'HS256'); }, 'HS256');
// should respond with unauthorized name guessing // should respond with not-found because we are root
var res = request.get({ var res = request.get({
url: baseUrl() + "/_db/nonexisting/_api/version", url: baseUrl() + "/_db/nonexisting/_api/version",
auth: { auth: {
@ -503,7 +503,14 @@ function AuthSuite() {
} }
}); });
expect(res).to.be.an.instanceof(request.Response); expect(res).to.be.an.instanceof(request.Response);
expect(res).to.have.property('statusCode', 401); expect(res).to.have.property('statusCode', 404);
// should prevent name guessing by unauthorized users
var res = request.get({
url: baseUrl() + "/_db/nonexisting/_api/version"
});
expect(res).to.be.an.instanceof(request.Response);
expect(res).to.have.property('statusCode', 404);
}, },
testDatabaseListNonSystem: function() { testDatabaseListNonSystem: function() {