From 326821f66ed6286ee8b2ea6f5606d3eb902489fc Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 11 Nov 2016 12:59:43 +0000 Subject: [PATCH] reduce useraccouts cache time --- .../UserAccounts/UserAccountCache.cs | 6 +-- .../PasswordAuthenticationService.cs | 53 +------------------ 2 files changed, 5 insertions(+), 54 deletions(-) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs index 03cb680a0a..6c1cc525b2 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/UserAccountCache.cs @@ -36,8 +36,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts { public class UserAccountCache : IUserAccountCacheModule { - private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours! - private const double CACHENULL_EXPIRATION_SECONDS = 600; // 10minutes + private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour! + private const double CACHE_NULL_EXPIRATION_SECONDS = 600; // 10minutes // private static readonly ILog m_log = // LogManager.GetLogger( @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts lock(accessLock) { if (account == null) - m_UUIDCache.AddOrUpdate(userID, null, CACHENULL_EXPIRATION_SECONDS); + m_UUIDCache.AddOrUpdate(userID, null, CACHE_NULL_EXPIRATION_SECONDS); else { m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS); diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index a9359f3cd0..2e8ffe5aae 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -72,11 +72,8 @@ namespace OpenSim.Services.AuthenticationService { realID = UUID.Zero; - m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}, user account service present: {1}", principalID, m_UserAccountService != null); + m_log.DebugFormat("[AUTH SERVICE]: Authenticating for {0}", principalID); AuthenticationData data = m_Database.Get(principalID); - UserAccount user = null; - if (m_UserAccountService != null) - user = m_UserAccountService.GetUserAccount(UUID.Zero, principalID); if (data == null || data.Data == null) { @@ -100,53 +97,7 @@ namespace OpenSim.Services.AuthenticationService return GetToken(principalID, lifetime); } - if (user == null) - { - m_log.DebugFormat("[PASS AUTH]: No user record for {0}", principalID); - return String.Empty; - } - - int impersonateFlag = 1 << 6; - - if ((user.UserFlags & impersonateFlag) == 0) - return String.Empty; - - m_log.DebugFormat("[PASS AUTH]: Attempting impersonation"); - - List accounts = m_UserAccountService.GetUserAccountsWhere(UUID.Zero, "UserLevel >= 200"); - if (accounts == null || accounts.Count == 0) - return String.Empty; - - foreach (UserAccount a in accounts) - { - data = m_Database.Get(a.PrincipalID); - if (data == null || data.Data == null || - !data.Data.ContainsKey("passwordHash") || - !data.Data.ContainsKey("passwordSalt")) - { - continue; - } - -// m_log.DebugFormat("[PASS AUTH]: Trying {0}", data.PrincipalID); - - hashed = Util.Md5Hash(password + ":" + - data.Data["passwordSalt"].ToString()); - - if (data.Data["passwordHash"].ToString() == hashed) - { - m_log.DebugFormat("[PASS AUTH]: {0} {1} impersonating {2}, proceeding with login", a.FirstName, a.LastName, principalID); - realID = a.PrincipalID; - return GetToken(principalID, lifetime); - } -// else -// { -// m_log.DebugFormat( -// "[AUTH SERVICE]: Salted hash {0} of given password did not match salted hash of {1} for PrincipalID {2}. Authentication failure.", -// hashed, data.Data["passwordHash"], data.PrincipalID); -// } - } - - m_log.DebugFormat("[PASS AUTH]: Impersonation of {0} failed", principalID); + m_log.DebugFormat("[AUTH SERVICE]: Authenticating FAIL for {0} ", principalID); return String.Empty; } }