From 11700ba4a4e35cf7512f7f6e8b9b8e54e812f574 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 07:03:43 +0100 Subject: Implement plain password authentication partway. Tested, but no user functionality yet. --- .../AuthenticationServiceBase.cs | 15 ++++++++++++ .../PasswordAuthenticationService.cs | 28 +++++++++++++--------- .../WebkeyAuthenticationService.cs | 12 +--------- 3 files changed, 33 insertions(+), 22 deletions(-) (limited to 'OpenSim/Services/AuthenticationService') diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 200268b..dab0598 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -95,6 +95,16 @@ namespace OpenSim.Services.AuthenticationService return new byte[0]; } + public bool Verify(UUID principalID, string token, int lifetime) + { + return false; + } + + public bool VerifyEncrypted(byte[] cyphertext, byte[] key) + { + return false; + } + public virtual bool Release(UUID principalID, string token) { return false; @@ -104,5 +114,10 @@ namespace OpenSim.Services.AuthenticationService { return false; } + + protected string GetToken(UUID principalID, int lifetime) + { + return "OK"; + } } } diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 83ce0d0..7fdbbf6 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -56,8 +56,24 @@ namespace OpenSim.Services.AuthenticationService { } - public string Authenticate(UUID principalID, string password) + public string Authenticate(UUID principalID, string password, int lifetime) { + AuthenticationData data = m_Database.Get(principalID); + + if (!data.Data.ContainsKey("passwordHash") || + !data.Data.ContainsKey("passwordSalt")) + { + return String.Empty; + } + + string hashed = Util.Md5Hash(Util.Md5Hash(password) + ":" + + data.Data["passwordSalt"].ToString()); + + if (data.Data["passwordHash"].ToString() == hashed) + { + return GetToken(principalID, lifetime); + } + return String.Empty; } @@ -65,15 +81,5 @@ namespace OpenSim.Services.AuthenticationService { return new byte[0]; } - - public bool Verify(UUID principalID, string token) - { - return false; - } - - public bool VerifyEncrypted(byte[] cyphertext, byte[] key) - { - return false; - } } } diff --git a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs index af55df0..0118c91 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyAuthenticationService.cs @@ -52,7 +52,7 @@ namespace OpenSim.Services.AuthenticationService { } - public string Authenticate(UUID principalID, string password) + public string Authenticate(UUID principalID, string password, int lifetime) { return String.Empty; } @@ -61,15 +61,5 @@ namespace OpenSim.Services.AuthenticationService { return new byte[0]; } - - public bool Verify(UUID principalID, string token) - { - return false; - } - - public bool VerifyEncrypted(byte[] cyphertext, byte[] key) - { - return false; - } } } -- cgit v1.1 From ac40c7a74c15e0f61ba5bfcb4c6a6fb39993a87c Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 07:48:09 +0100 Subject: Fully implement unencrypted auth token operations --- .../AuthenticationService/AuthenticationServiceBase.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services/AuthenticationService') diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index dab0598..5056db3 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -97,7 +97,7 @@ namespace OpenSim.Services.AuthenticationService public bool Verify(UUID principalID, string token, int lifetime) { - return false; + return m_Database.CheckToken(principalID, token, lifetime); } public bool VerifyEncrypted(byte[] cyphertext, byte[] key) @@ -107,7 +107,7 @@ namespace OpenSim.Services.AuthenticationService public virtual bool Release(UUID principalID, string token) { - return false; + return m_Database.CheckToken(principalID, token, 0); } public virtual bool ReleaseEncrypted(byte[] cyphertext, byte[] key) @@ -117,7 +117,12 @@ namespace OpenSim.Services.AuthenticationService protected string GetToken(UUID principalID, int lifetime) { - return "OK"; + UUID token = UUID.Random(); + + if (m_Database.SetToken(principalID, token.ToString(), lifetime)) + return token.ToString(); + + return String.Empty; } } } -- cgit v1.1 From 67f803c919324f49e21279faa43c9578b625529e Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 4 Sep 2009 08:10:05 +0100 Subject: Add the new AuthStore to migrations. Update OpenSim.Server.ini --- OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services/AuthenticationService') diff --git a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs index 5056db3..2ed177c 100644 --- a/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs +++ b/OpenSim/Services/AuthenticationService/AuthenticationServiceBase.cs @@ -53,7 +53,7 @@ namespace OpenSim.Services.AuthenticationService { string dllName = String.Empty; string connString = String.Empty; - string realm = String.Empty; + string realm = "auth"; // // Try reading the [AuthenticationService] section first, if it exists -- cgit v1.1