mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2026-06-13 14:38:43 +00:00
Protocol Phase 1 (Auth)
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Esiur.Tests.Functional
|
||||
{
|
||||
internal class ClientAuthenticationProvider : PasswordAuthenticationProvider
|
||||
{
|
||||
public override (byte[], byte[]) GetHostedAccountCredential(string identity, string domain)
|
||||
public override PasswordHash GetHostedAccountCredential(string identity, string domain)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -23,12 +23,12 @@ namespace Esiur.Tests.Functional
|
||||
return null;
|
||||
}
|
||||
|
||||
public override (string, byte[]) GetSelfIdentityAndCredential(string domain, string hostname)
|
||||
public override IdentityPassword GetSelfIdentityAndCredential(string domain, string hostname)
|
||||
{
|
||||
if (domain == "test" && hostname == "localhost")
|
||||
return ("tester", new byte[] { 1, 2, 3, 4, 5 });
|
||||
return new IdentityPassword { Identity = "tester", Password = new byte[] { 1, 2, 3, 4, 5 } };
|
||||
else
|
||||
return (null, null);
|
||||
return new IdentityPassword { Identity = null, Password = null };
|
||||
}
|
||||
|
||||
public override AsyncReply<bool> Login(Session session)
|
||||
|
||||
@@ -50,6 +50,7 @@ using Esiur.Net.Packets;
|
||||
using System.Numerics;
|
||||
using Esiur.Protocol;
|
||||
using Esiur.Security.Authority.Providers;
|
||||
using Esiur.Security.Authority;
|
||||
|
||||
namespace Esiur.Tests.Functional;
|
||||
|
||||
@@ -144,10 +145,11 @@ class Program
|
||||
|
||||
var wh = new Warehouse();
|
||||
wh.RegisterAuthenticationProvider(new ServerAuthenticationProvider());
|
||||
|
||||
|
||||
// Create stores to keep objects.
|
||||
var system = await wh.Put("sys", new MemoryStore());
|
||||
var server = await wh.Put("sys/server", new EpServer() {
|
||||
var server = await wh.Put("sys/server", new EpServer()
|
||||
{
|
||||
AllowedAuthenticationProviders = new string[] { "hash" },
|
||||
});
|
||||
|
||||
@@ -218,16 +220,18 @@ class Program
|
||||
var auth = new ClientAuthenticationProvider();
|
||||
wh.RegisterAuthenticationProvider(auth);
|
||||
|
||||
var con = await wh.Get<EpConnection>("EP://localhost", new EpConnectionContext
|
||||
var con = await wh.Get<EpConnection>("ep://localhost", new EpConnectionContext
|
||||
{
|
||||
AuthenticationMode = AuthenticationMode.InitializerIdentity,
|
||||
AutoReconnect = true,
|
||||
Identity = "tester",
|
||||
AuthenticationProtocol = "hash"
|
||||
AuthenticationProtocol = "hash",
|
||||
Domain = "test",
|
||||
});
|
||||
|
||||
|
||||
dynamic remote = await con.Get("sys/service");
|
||||
|
||||
dynamic remote = await con.Get("sys/service");
|
||||
|
||||
TestObjectProps(local, remote);
|
||||
|
||||
//return;
|
||||
|
||||
@@ -7,24 +7,25 @@ using System.Text;
|
||||
|
||||
namespace Esiur.Tests.Functional
|
||||
{
|
||||
internal class ServerAuthenticationProvider: PasswordAuthenticationProvider
|
||||
internal class ServerAuthenticationProvider : PasswordAuthenticationProvider
|
||||
{
|
||||
public override (byte[], byte[]) GetHostedAccountCredential(string identity, string domain)
|
||||
public override PasswordHash GetHostedAccountCredential(string identity, string domain)
|
||||
{
|
||||
if (identity == "tester" && domain == "test")
|
||||
return (new byte[] { 1, 2, 3, 4, 5 }, new byte[] { 6, 7, 8, 9, 10 });
|
||||
return new PasswordHash(PasswordAuthenticationHandler.ComputeSha3(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }),
|
||||
new byte[] { 6, 7, 8, 9, 10 });
|
||||
else
|
||||
return (null, null);
|
||||
return new PasswordHash(null, null);
|
||||
}
|
||||
|
||||
public override byte[] GetSelfCredential(string identity, string domain, string hostname)
|
||||
{
|
||||
return base.GetSelfCredential(identity, domain, hostname);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override (string, byte[]) GetSelfIdentityAndCredential(string domain, string hostname)
|
||||
public override IdentityPassword GetSelfIdentityAndCredential(string domain, string hostname)
|
||||
{
|
||||
return base.GetSelfIdentityAndCredential(domain, hostname);
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override AsyncReply<bool> Login(Session session)
|
||||
|
||||
Reference in New Issue
Block a user