0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/db/security.cpp

65 lines
1.9 KiB
C++
Raw Normal View History

2009-01-19 01:13:12 +01:00
// security.cpp
2009-01-23 17:28:29 +01:00
/**
* Copyright (C) 2009 10gen Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2010-04-27 21:27:52 +02:00
#include "pch.h"
2009-01-19 01:13:12 +01:00
#include "security.h"
#include "instance.h"
#include "client.h"
#include "curop.h"
#include "db.h"
#include "dbhelpers.h"
2009-01-19 01:13:12 +01:00
namespace mongo {
2009-01-19 02:31:33 +01:00
bool noauth = true;
int AuthenticationInfo::warned = 0;
void AuthenticationInfo::print(){
2010-04-20 18:29:00 +02:00
cout << "AuthenticationInfo: " << this << '\n';
for ( map<string,Auth>::iterator i=m.begin(); i!=m.end(); i++ ){
2010-04-20 18:29:00 +02:00
cout << "\t" << i->first << "\t" << i->second.level << '\n';
}
cout << "END" << endl;
}
bool AuthenticationInfo::_isAuthorizedSpecialChecks( const string& dbname ) {
if ( cc().isGod() ){
return true;
}
if ( isLocalHost ){
2010-02-25 19:47:59 +01:00
atleastreadlock l("");
Client::GodScope gs;
Client::Context c("admin.system.users");
BSONObj result;
if( ! Helpers::getSingleton("admin.system.users", result) ){
if( warned == 0 ) {
warned++;
log() << "note: no users configured in admin.system.users, allowing localhost access" << endl;
}
return true;
}
}
return false;
}
2009-01-19 01:13:12 +01:00
} // namespace mongo