2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-05-06 11:32:59 +00:00
This commit is contained in:
Ahmed Zamil 2024-03-25 01:57:29 +03:00
commit 81f9f92755
7 changed files with 66 additions and 3 deletions

View File

@ -833,7 +833,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
}
}
//Console.WriteLine(msg.GetString(offset, ends - offset));
var rt = authPacket.Parse(msg, offset, ends);
@ -1032,6 +1032,7 @@ public partial class DistributedConnection : NetworkConnection, IStore
//SendParams((byte)0, localHash);
var localHash = hashFunc.ComputeHash((new BinaryList()).AddUInt8Array(localNonce).AddUInt8Array(remoteNonce).AddUInt8Array(pw).ToArray());
SendParams().AddUInt8(0).AddUInt8Array(localHash).Done();
readyToEstablish = true;

View File

@ -55,7 +55,6 @@ public class Session
public Session(Authentication localAuthentication, Authentication remoteAuthentication)
{
this.localAuth = localAuthentication;
this.remoteAuth = remoteAuthentication;
}

View File

@ -0,0 +1,13 @@
using Esiur.Security.Authority;
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Security.Membership
{
public class AuthorizationResponse
{
public Session Session { get; set; }
public bool Succeeded { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Security.Membership
{
public class AuthorizationResults
{
AuthorizationResultsResponse Response { get; set; }
TwoFactorAuthorizationMethod TwoFactorMethod { get; set; }
public string Clue { get; set; }
public string AppName { get; set; }
public string Code { get; set; }
public int Timeout { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Security.Membership
{
public enum AuthorizationResultsResponse
{
Success,
ServiceUnavailable,
TwoFactoryAuthorization,
}
}

View File

@ -1,6 +1,6 @@
/*
Copyright (c) 2017 Ahmed Kh. Zamil
Copyright (c) 2017-2024 Ahmed Kh. Zamil
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -37,11 +37,17 @@ namespace Esiur.Security.Membership;
public interface IMembership
{
public event ResourceEventHandler<AuthorizationResponse> Authorization;
AsyncReply<bool> UserExists(string username, string domain);
AsyncReply<byte[]> GetPassword(string username, string domain);
AsyncReply<byte[]> GetToken(ulong tokenIndex, string domain);
AsyncReply<AuthorizationResults> Authorize(Session session);
AsyncReply<bool> Login(Session session);
AsyncReply<bool> Logout(Session session);
bool GuestsAllowed { get; }
AsyncReply<string> TokenExists(ulong tokenIndex, string domain);
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Esiur.Security.Membership
{
public enum TwoFactorAuthorizationMethod
{
Email,
SMS,
App,
}
}