Permalink
Browse files

fix getLog auth SERVER-4695

  • Loading branch information...
1 parent 0b38e10 commit 68e305862aad6c618211d4e100768a62834d6d2a @erh erh committed Jan 17, 2012
Showing with 9 additions and 1 deletion.
  1. +1 −1 db/dbcommands_generic.cpp
  2. +8 −0 jstests/auth/auth1.js
View
2 db/dbcommands_generic.cpp
@@ -334,7 +334,7 @@ namespace mongo {
virtual bool slaveOk() const { return true; }
virtual LockType locktype() const { return NONE; }
- virtual bool requiresAuth() { return false; }
+ virtual bool requiresAuth() { return true; }
virtual bool adminOnly() const { return true; }
virtual void help( stringstream& help ) const {
View
8 jstests/auth/auth1.js
@@ -16,6 +16,14 @@ db.addUser( "eliot" , "eliot" );
db.addUser( "guest" , "guest", true );
db.getSisterDB( "admin" ).addUser( "super", "super" );
+print("make sure we can't run certain commands w/out auth");
+var errmsg = "need to login";
+res = db.adminCommand({getLog : "global"});
+printjson( res );
+assert( ! res.log || res.log.length == 0 , "getLog should fail: " + tojson( res ) )
+assert.eq( res.errmsg , "need to login" , tojson( res ) );
+
+
assert.throws( function() { t.findOne() }, [], "read without login" );
assert( db.auth( "eliot" , "eliot" ) , "auth failed" );

0 comments on commit 68e3058

Please sign in to comment.