[SERVER-1677] A shell function should be implemented to see if the server is running with authentication Created: 25/Aug/10  Updated: 06/Dec/22  Resolved: 17/Aug/18

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 1.6.1
Fix Version/s: None

Type: New Feature Priority: Minor - P4
Reporter: Justin Dearing Assignee: Backlog - Security Team
Resolution: Done Votes: 2
Labels: platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Issue Links:
Related
is related to SERVER-1698 A shell function should be implemente... Closed
Assigned Teams:
Server Security
Participants:

 Description   

A function, whose name I propose to be authEnabled() should return true if the mongo server has authentication enabled, false otherwise.



 Comments   
Comment by Matt Lord (Inactive) [ 17/Aug/18 ]

Hi halfdan,

Since the original stated problem "use getCmdLineOpts() to determine if MongoDB runs in auth-Mode, but this does not work if authentication has been enabled in mongodb.conf" is now addressed in MongoDB 4.0 I'm going to close this ticket for now.

mongolord:mongodb-osx-x86_64-enterprise-4.0.1 matt$ cat /tmp/mongo-auth.conf 
security:
  authorization: enabled
 
mongolord:mongodb-osx-x86_64-enterprise-4.0.1 matt$ ./bin/mongod -f /tmp/mongo-auth.conf --quiet --dbpath=./data --logpath=./data/mongodb.log --fork 
2018-08-17T15:12:26.111-0400 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
about to fork child process, waiting until server is ready for connections.
forked process: 77476
child process started successfully, parent exiting
 
mongolord:mongodb-osx-x86_64-enterprise-4.0.1 matt$ ./bin/mongo -u root -p"root" --authenticationDatabase=admin 
MongoDB shell version v4.0.1
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.1
 
test@mongolord> db.serverCmdLineOpts()
{
	"argv" : [
		"./bin/mongod",
		"-f",
		"/tmp/mongo-auth.conf",
		"--quiet",
		"--dbpath=./data",
		"--logpath=./data/mongodb.log",
		"--fork"
	],
	"parsed" : {
		"config" : "/tmp/mongo-auth.conf",
		"processManagement" : {
			"fork" : true
		},
		"security" : {
			"authorization" : "enabled"
		},
		"storage" : {
			"dbPath" : "./data"
		},
		"systemLog" : {
			"destination" : "file",
			"path" : "./data/mongodb.log",
			"quiet" : true
		}
	},
	"ok" : 1
}
test@mongolord>

Please let me know if you'd still like something more in this regard and I will re-open the ticket and adjust it as needed. 

 

Thank you for using MongoDB!

Comment by Asya Kamsky [ 16/Aug/18 ]

This can be done with `getCmdLineOpts` as since that comment was made, it displays options whether they were specified on the command line or in the config file.

 

Comment by Eliot Horowitz (Inactive) [ 13/Jul/11 ]

I think it was meant as a related link, not depends.

Comment by Fabian Becker [ 13/Jul/11 ]

@Kristina: I don't see why this is a duplicate of my other ticket. SERVER-1698 is asking for a method to tell whether a user isAuthenticated with the database, this ticket asks for a method to tell whether the server requires authentication.

Comment by Fabian Becker [ 25/Aug/10 ]

http://groups.google.com/group/mongodb-dev/browse_thread/thread/bb8a7fea2fdb8cec?hl=en

C&P from my Post in the Group:
"While writing a small UI for Mongo it was becoming quite hard to handle authentication as there is no direct way of determining if the database requires authentication. It would help to have a MongoDB::requiresAuthentication() method with which one can tell if the database requires auth."

Kristina suggested to use "getCmdLineOpts" to determine if MongoDB runs in auth-Mode, but this does not work if authentication has been enabled in mongodb.conf.

This function would be much appreciated if implemented!t

Generated at Thu Feb 08 02:57:43 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.