4
* Copyright (C) 2009 10gen Inc.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License, version 3,
8
* as published by the Free Software Foundation.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Affero General Public License for more details.
15
* You should have received a copy of the GNU Affero General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
#include <boost/thread/tss.hpp>
23
#define assert xassert
26
#include "dbhelpers.h"
31
// --noauth cmd line option
34
/* for a particular db */
40
class AuthenticationInfo : boost::noncopyable {
41
map<string, Auth> m; // dbname -> auth
45
AuthenticationInfo() { isLocalHost = false; }
46
virtual ~AuthenticationInfo() {
48
void logout(const char *dbname) {
52
void authorize(const char *dbname) {
56
virtual bool isAuthorized(const char *dbname) {
57
if( m[dbname].level == 2 ) return true;
58
if( noauth ) return true;
59
if( m["admin"].level == 2 ) return true;
60
if( m["local"].level == 2 ) return true;
63
Client::Context c("admin.system.users");
65
if( Helpers::getSingleton("admin.system.users", result) )
69
log() << "warning: no users configured in admin.system.users, allowing localhost access" << endl;