Skip to content

Commit 10ce647

Browse files
committed
SERVER-7572 Move internalSecurity information into authorization_manager
1 parent 935d9de commit 10ce647

File tree

12 files changed

+29
-17
lines changed

12 files changed

+29
-17
lines changed

src/mongo/db/auth/authorization_manager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
namespace mongo {
3636

37+
AuthInfo::AuthInfo() {
38+
user = "__system";
39+
}
40+
AuthInfo internalSecurity;
41+
3742
const std::string AuthorizationManager::SERVER_RESOURCE_NAME = "$SERVER";
3843
const std::string AuthorizationManager::CLUSTER_RESOURCE_NAME = "$CLUSTER";
3944

@@ -251,8 +256,7 @@ namespace mongo {
251256
<< principal->getName(),
252257
0);
253258
}
254-
// TODO: move internalSecurity into AuthorizationManager
255-
if (principal->getName() == "__system") {
259+
if (principal->getName() == internalSecurity.user) {
256260
// Grant full access to internal user
257261
ActionSet allActions;
258262
allActions.addAllActions();

src/mongo/db/auth/authorization_manager.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131

3232
namespace mongo {
3333

34+
/**
35+
* Internal secret key info.
36+
*/
37+
struct AuthInfo {
38+
AuthInfo();
39+
string user;
40+
string pwd;
41+
};
42+
extern AuthInfo internalSecurity; // set at startup and not changed after initialization.
43+
3444
/**
3545
* Contains all the authorization logic for a single client connection. It contains a set of
3646
* the principals which have been authenticated, as well as a set of privileges that have been

src/mongo/db/commands/isself.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818

1919
#include "pch.h"
20+
21+
#include "mongo/db/auth/authorization_manager.h"
2022
#include "../../util/net/listen.h"
2123
#include "../commands.h"
2224
#include "../security.h"

src/mongo/db/repl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#include <boost/thread/thread.hpp>
3232

33+
#include "mongo/db/auth/authorization_manager.h"
3334
#include "jsobj.h"
3435
#include "../util/goodies.h"
3536
#include "repl.h"

src/mongo/db/repl/connections.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#pragma once
2020

2121
#include <map>
22-
#include "../security_common.h"
22+
23+
#include "mongo/db/auth/authorization_manager.h"
2324

2425
namespace mongo {
2526

src/mongo/db/security.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818

1919
#include "pch.h"
20+
21+
#include "mongo/db/auth/authorization_manager.h"
2022
#include "security.h"
2123
#include "security_common.h"
2224
#include "instance.h"

src/mongo/db/security_common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <sys/stat.h>
2727

28+
#include "mongo/db/auth/authorization_manager.h"
2829
#include "security.h"
2930
#include "security_common.h"
3031
#include "commands.h"
@@ -38,8 +39,6 @@ namespace mongo {
3839
// this is a config setting, set at startup and not changing after initialization.
3940
bool noauth = true;
4041

41-
AuthInfo internalSecurity;
42-
4342
bool setUpSecurityKey(const string& filename) {
4443
struct stat stats;
4544

src/mongo/db/security_common.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,8 @@
2323

2424
namespace mongo {
2525

26-
/**
27-
* Internal secret key info.
28-
*/
29-
struct AuthInfo {
30-
AuthInfo() {
31-
user = "__system";
32-
}
33-
string user;
34-
string pwd;
35-
};
36-
3726
// --noauth cmd line option
3827
extern bool noauth;
39-
extern AuthInfo internalSecurity; // set at startup and not changed after initialization.
4028

4129
/**
4230
* This method checks the validity of filename as a security key, hashes its

src/mongo/s/d_migrate.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include <boost/thread/thread.hpp>
3131

32+
#include "mongo/db/auth/authorization_manager.h"
3233
#include "mongo/db/dbhelpers.h"
3334
#include "../db/commands.h"
3435
#include "mongo/db/hasher.h"

src/mongo/s/security.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// security.cpp
1919

2020
#include "pch.h"
21+
22+
#include "mongo/db/auth/authorization_manager.h"
2123
#include "../db/security_common.h"
2224
#include "../db/security.h"
2325
#include "config.h"

0 commit comments

Comments
 (0)