Skip to content

Commit

Permalink
fixed DbIdentityManager requires mongodb user with listDatabases perm…
Browse files Browse the repository at this point in the history
  • Loading branch information
ujibang committed Feb 17, 2017
1 parent a11abd0 commit 6225620
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/main/java/org/restheart/security/impl/DbIdentityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.restheart.cache.Cache;
import org.restheart.cache.CacheFactory;
import org.restheart.cache.LoadingCache;
import org.restheart.db.DbsDAO;
import org.restheart.db.MongoDBClientSingleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -93,28 +94,8 @@ public DbIdentityManager(Map<String, Object> arguments)
MongoClient mongoClient = MongoDBClientSingleton
.getInstance().getClient();

ArrayList<String> dbNames = new ArrayList<>();

mongoClient.listDatabaseNames().into(dbNames);

if (!dbNames.contains(this.db)) {
throw new IllegalArgumentException(
"error configuring the DbIdentityManager. "
+ "The specified db does not exist: " + db);
}

MongoDatabase mongoDb = mongoClient.getDatabase(this.db);

ArrayList<String> collectionNames = new ArrayList<>();

mongoDb.listCollectionNames().into(collectionNames);

if (!collectionNames.contains(this.coll)) {
throw new IllegalArgumentException(
"error configuring the DbIdentityManager. "
+ "The specified collection does not exist: " + coll);
}

this.mongoColl = mongoDb.getCollection(coll, BsonDocument.class);
}

Expand Down

0 comments on commit 6225620

Please sign in to comment.