mirror of https://gitee.com/bigwinds/arangodb
some minor refactoring preparations
This commit is contained in:
parent
2e1c7fcea6
commit
8875243c66
|
@ -125,7 +125,7 @@ static AuthEntry CreateAuthEntry(VPackSlice const& slice) {
|
|||
|
||||
// build authentication entry
|
||||
return AuthEntry(userSlice.copyString(), methodSlice.copyString(),
|
||||
saltSlice.copyString(), hashSlice.copyString(), databases,
|
||||
saltSlice.copyString(), hashSlice.copyString(), std::move(databases),
|
||||
allDatabases, active, mustChange);
|
||||
}
|
||||
|
||||
|
@ -149,6 +149,7 @@ std::string AuthInfo::jwtSecret() {
|
|||
return _jwtSecret;
|
||||
}
|
||||
|
||||
// private
|
||||
void AuthInfo::insertInitial() {
|
||||
if (!_authInfo.empty()) {
|
||||
return;
|
||||
|
@ -195,6 +196,7 @@ void AuthInfo::insertInitial() {
|
|||
}
|
||||
}
|
||||
|
||||
// private
|
||||
bool AuthInfo::populate(VPackSlice const& slice) {
|
||||
TRI_ASSERT(slice.isArray());
|
||||
|
||||
|
@ -213,6 +215,7 @@ bool AuthInfo::populate(VPackSlice const& slice) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// private
|
||||
void AuthInfo::reload() {
|
||||
auto role = ServerState::instance()->getRole();
|
||||
|
||||
|
@ -274,6 +277,7 @@ void AuthInfo::reload() {
|
|||
_outdated = false;
|
||||
}
|
||||
|
||||
// public
|
||||
AuthResult AuthInfo::checkPassword(std::string const& username,
|
||||
std::string const& password) {
|
||||
if (_outdated) {
|
||||
|
@ -353,6 +357,7 @@ AuthResult AuthInfo::checkPassword(std::string const& username,
|
|||
return result;
|
||||
}
|
||||
|
||||
// public
|
||||
AuthLevel AuthInfo::canUseDatabase(std::string const& username,
|
||||
std::string const& dbname) {
|
||||
if (_outdated) {
|
||||
|
@ -370,6 +375,7 @@ AuthLevel AuthInfo::canUseDatabase(std::string const& username,
|
|||
return entry.canUseDatabase(dbname);
|
||||
}
|
||||
|
||||
// public
|
||||
AuthResult AuthInfo::checkAuthentication(AuthType authType,
|
||||
std::string const& secret) {
|
||||
if (_outdated) {
|
||||
|
@ -387,6 +393,7 @@ AuthResult AuthInfo::checkAuthentication(AuthType authType,
|
|||
return AuthResult();
|
||||
}
|
||||
|
||||
// private
|
||||
AuthResult AuthInfo::checkAuthenticationBasic(std::string const& secret) {
|
||||
auto const& it = _authBasicCache.find(secret);
|
||||
|
||||
|
|
|
@ -49,17 +49,17 @@ class AuthEntry {
|
|||
public:
|
||||
AuthEntry() : _active(false), _mustChange(false), _allDatabases(AuthLevel::NONE) {}
|
||||
|
||||
AuthEntry(std::string const& username, std::string const& passwordMethod,
|
||||
std::string const& passwordSalt, std::string const& passwordHash,
|
||||
std::unordered_map<std::string, AuthLevel> const& databases, AuthLevel allDatabases,
|
||||
AuthEntry(std::string&& username, std::string&& passwordMethod,
|
||||
std::string&& passwordSalt, std::string&& passwordHash,
|
||||
std::unordered_map<std::string, AuthLevel>&& databases, AuthLevel allDatabases,
|
||||
bool active, bool mustChange)
|
||||
: _username(username),
|
||||
_passwordMethod(passwordMethod),
|
||||
_passwordSalt(passwordSalt),
|
||||
_passwordHash(passwordHash),
|
||||
: _username(std::move(username)),
|
||||
_passwordMethod(std::move(passwordMethod)),
|
||||
_passwordSalt(std::move(passwordSalt)),
|
||||
_passwordHash(std::move(passwordHash)),
|
||||
_active(active),
|
||||
_mustChange(mustChange),
|
||||
_databases(databases),
|
||||
_databases(std::move(databases)),
|
||||
_allDatabases(allDatabases) {}
|
||||
|
||||
public:
|
||||
|
@ -77,14 +77,14 @@ class AuthEntry {
|
|||
AuthLevel canUseDatabase(std::string const& dbname) const;
|
||||
|
||||
private:
|
||||
std::string _username;
|
||||
std::string _passwordMethod;
|
||||
std::string _passwordSalt;
|
||||
std::string _passwordHash;
|
||||
bool _active;
|
||||
std::string const _username;
|
||||
std::string const _passwordMethod;
|
||||
std::string const _passwordSalt;
|
||||
std::string const _passwordHash;
|
||||
bool const _active;
|
||||
bool _mustChange;
|
||||
std::unordered_map<std::string, AuthLevel> _databases;
|
||||
AuthLevel _allDatabases;
|
||||
std::unordered_map<std::string, AuthLevel> const _databases;
|
||||
AuthLevel const _allDatabases;
|
||||
};
|
||||
|
||||
class AuthResult {
|
||||
|
@ -120,7 +120,8 @@ class AuthInfo {
|
|||
void setQueryRegistry(aql::QueryRegistry* registry) {
|
||||
TRI_ASSERT(registry != nullptr);
|
||||
_queryRegistry = registry;
|
||||
};
|
||||
}
|
||||
|
||||
void outdate() { _outdated = true; }
|
||||
|
||||
AuthResult checkPassword(std::string const& username,
|
||||
|
|
Loading…
Reference in New Issue