Просмотр исходного кода

Merge pull request #3163 from weseek/fix/add-authentification-to-api-for-get-mongo-collections

add admin required to api for getting mongo collections
Yuki Takei 5 лет назад
Родитель
Сommit
c2b9f63a3e
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/server/routes/apiv3/mongo.js

+ 4 - 1
src/server/routes/apiv3/mongo.js

@@ -14,6 +14,9 @@ const router = express.Router();
  */
  */
 
 
 module.exports = (crowi) => {
 module.exports = (crowi) => {
+  const loginRequiredStrictly = require('../../middlewares/login-required')(crowi);
+  const adminRequired = require('../../middlewares/admin-required')(crowi);
+
   /**
   /**
    * @swagger
    * @swagger
    *
    *
@@ -35,7 +38,7 @@ module.exports = (crowi) => {
    *                    items:
    *                    items:
    *                      type: string
    *                      type: string
    */
    */
-  router.get('/collections', async(req, res) => {
+  router.get('/collections', loginRequiredStrictly, adminRequired, async(req, res) => {
     const listCollectionsResult = await mongoose.connection.db.listCollections().toArray();
     const listCollectionsResult = await mongoose.connection.db.listCollections().toArray();
     const collections = listCollectionsResult.map(collectionObj => collectionObj.name);
     const collections = listCollectionsResult.map(collectionObj => collectionObj.name);