简体   繁体   中英

How to disable server-side JavaScript on MongoDB from Java Application

I have a java web application that does CRUD ops on a MongoDB Atlas instance. I want to disable server-side JavaScript for my Atlas instance from my Java web application.
What I have found out are this and this which basically say that I need to either alter the mongod.conf file or use the command line args --noscripting on mongod command. But I want to accomplish this using my Java web application when the web app starts.

Does the MongoDB java driver provide a mechanism to achieve this?
Are there any alternate ways to get this done?

Note: I do not want to pass mongod command from my web application.

Does the MongoDB java driver provide a mechanism to achieve this?

The option to enable or disable server-side JavaScript can only be set in the MongoDB server configuration on startup; it is not possible to change via a driver or runtime API call.

Since MongoDB Atlas is a managed service, end users do not have direct access to MongoDB server configuration and are limited to options exposed via the admin UI.

MongoDB Atlas does not currently allow configuring the security.javascriptEnabled value: server-side JavaScript execution is disabled for free/shared clusters (M0, M2, M5) and enabled for M10+ clusters.

Are there any alternate ways to get this done?

If you have an M10+ MongoDB Atlas cluster (which currently has JavaScript execution enabled by default) you can open a support case and ask if it would be possible to disable server-side JavaScript for your cluster. Customer requests/feedback are one signal that would encourage either changing the default value in MongoDB Atlas or making it configurable via UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM