mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Implements authentication system
This commit is contained in:
1 parent
38829d64ff
commit
a6dcf65d1c
103 files changed
+2983
-454
No files matched your search
@@ -0,0 +1,15 @@
|
||||
namespace Lumina.Application.Common.Infrastructure.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for generating JWT tokens.
|
||||
/// </summary>
|
||||
public interface IJwtTokenGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a new JWT token.
|
||||
/// </summary>
|
||||
/// <param name="id">The id of the user for which to generate the token.</param>
|
||||
/// <param name="username">The username for which to generate the token.</param>
|
||||
/// <returns>The generated JWT token.</returns>
|
||||
string GenerateToken(string id, string username);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Lumina.Application.Common.Infrastructure.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for generating QR codes for TOTP.
|
||||
/// </summary>
|
||||
public interface IQRCodeGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a QR code Data URI for the specified TOTP secret.
|
||||
/// </summary>
|
||||
/// <param name="username">User's username or unique identifier.</param>
|
||||
/// <param name="secret">The TOTP secret for which the QR code should be generated.</param>
|
||||
/// <returns>Data URI for the QR code.</returns>
|
||||
string GenerateQrCodeDataUri(string username, byte[] secret);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Lumina.Application.Common.Infrastructure.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for generating secure tokens for accounts confirmation or recovery.
|
||||
/// </summary>
|
||||
public interface ITokenGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a secure token.
|
||||
/// </summary>
|
||||
/// <returns>A secure token.</returns>
|
||||
string GenerateToken();
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace Lumina.Application.Common.Infrastructure.Authentication;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for generating and validating TOTP tokens.
|
||||
/// </summary>
|
||||
public interface ITotpTokenGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Generates a new TOTP secret for a user.
|
||||
/// </summary>
|
||||
/// <returns>The generated TOTP secret.</returns>
|
||||
byte[] GenerateSecret();
|
||||
|
||||
/// <summary>
|
||||
/// Validates a TOTP token against the stored secret.
|
||||
/// </summary>
|
||||
/// <param name="secret">The user's TOTP secret.</param>
|
||||
/// <param name="token">The token to validate.</param>
|
||||
/// <returns><see langword="true"/> if valid, <see langword="false"/> otherwise.</returns>
|
||||
bool ValidateToken(byte[] secret, string token);
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure;
|
||||
namespace Lumina.Application.Common.Infrastructure.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for cryptographic concerns.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Lumina.Application.Common.Infrastructure;
|
||||
namespace Lumina.Application.Common.Infrastructure.Security;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for the service for hashing passwords.
|
||||
@@ -0,0 +1,16 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Time;
|
||||
|
||||
/// <summary>
|
||||
/// Interface for time related concerns.
|
||||
/// </summary>
|
||||
public interface IDateTimeProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The current UTC time.
|
||||
/// </summary>
|
||||
DateTime UtcNow { get; }
|
||||
}
|
||||
Reference in new issue
Block a user