@@ -71,7 +71,7 @@
byte[] passwordHash = await Encryption.DeriveKeyFromPasswordAsync(RegisterModel.Password, salt);
var passwordHashString = BitConverter.ToString(passwordHash).Replace("-", string.Empty);
- var srpSignup = Cryptography.Srp.SignupPrepareAsync(client, salt, RegisterModel.Email, passwordHashString);
+ var srpSignup = Cryptography.Srp.SignupPrepareAsync(client, salt, RegisterModel.Username, passwordHashString);
var result = await Http.PostAsJsonAsync("api/v1/Auth/register", srpSignup);
var responseContent = await result.Content.ReadAsStringAsync();
diff --git a/src/AliasVault.Shared/Models/LoginModel.cs b/src/AliasVault.Shared/Models/LoginModel.cs
index e39e40c04..5be4e71da 100644
--- a/src/AliasVault.Shared/Models/LoginModel.cs
+++ b/src/AliasVault.Shared/Models/LoginModel.cs
@@ -15,11 +15,10 @@ using System.ComponentModel.DataAnnotations;
public class LoginModel
{
///
- /// Gets or sets the email.
+ /// Gets or sets the username.
///
[Required]
- [EmailAddress]
- public string Email { get; set; } = null!;
+ public string Username { get; set; } = null!;
///
/// Gets or sets the password.
diff --git a/src/AliasVault.Shared/Models/RegisterModel.cs b/src/AliasVault.Shared/Models/RegisterModel.cs
index 42c0dfd95..f6eb8160a 100644
--- a/src/AliasVault.Shared/Models/RegisterModel.cs
+++ b/src/AliasVault.Shared/Models/RegisterModel.cs
@@ -16,11 +16,10 @@ using AliasVault.Shared.Models.Validation;
public class RegisterModel
{
///
- /// Gets or sets the email.
+ /// Gets or sets the username.
///
[Required]
- [EmailAddress]
- public string Email { get; set; } = null!;
+ public string Username { get; set; } = null!;
///
/// Gets or sets the password.
diff --git a/src/AliasVault.Shared/Models/WebApi/Auth/LoginRequest.cs b/src/AliasVault.Shared/Models/WebApi/Auth/LoginRequest.cs
index 1243a8167..6b15bbc77 100644
--- a/src/AliasVault.Shared/Models/WebApi/Auth/LoginRequest.cs
+++ b/src/AliasVault.Shared/Models/WebApi/Auth/LoginRequest.cs
@@ -15,14 +15,14 @@ public class LoginRequest
///
/// Initializes a new instance of the class.
///
- /// Email.
- public LoginRequest(string email)
+ /// Username.
+ public LoginRequest(string username)
{
- Email = email;
+ Username = username.ToLowerInvariant().Trim();
}
///
- /// Gets or sets the email address.
+ /// Gets the username.
///
- public string Email { get; set; }
+ public string Username { get; }
}
diff --git a/src/AliasVault.Shared/Models/WebApi/Auth/ValidateLoginRequest.cs b/src/AliasVault.Shared/Models/WebApi/Auth/ValidateLoginRequest.cs
index ea5d391dd..88e4b9971 100644
--- a/src/AliasVault.Shared/Models/WebApi/Auth/ValidateLoginRequest.cs
+++ b/src/AliasVault.Shared/Models/WebApi/Auth/ValidateLoginRequest.cs
@@ -15,29 +15,29 @@ namespace AliasVault.Shared.Models.WebApi.Auth
///
/// Initializes a new instance of the class.
///
- /// Email.
+ /// Username.
/// Client public ephemeral.
/// Client session proof.
- public ValidateLoginRequest(string email, string clientPublicEphemeral, string clientSessionProof)
+ public ValidateLoginRequest(string username, string clientPublicEphemeral, string clientSessionProof)
{
- Email = email;
+ Username = username.ToLowerInvariant().Trim();
ClientPublicEphemeral = clientPublicEphemeral;
ClientSessionProof = clientSessionProof;
}
///
- /// Gets or sets the email.
+ /// Gets the username.
///
- public string Email { get; set; }
+ public string Username { get; }
///
- /// Gets or sets the client's public ephemeral value.
+ /// Gets the client's public ephemeral value.
///
- public string ClientPublicEphemeral { get; set; }
+ public string ClientPublicEphemeral { get; }
///
- /// Gets or sets the client's session proof.
+ /// Gets the client's session proof.
///
- public string ClientSessionProof { get; set; }
+ public string ClientSessionProof { get; }
}
}
diff --git a/src/Utilities/Cryptography/Models/SrpSignup.cs b/src/Utilities/Cryptography/Models/SrpSignup.cs
index 68e867c2f..954fb3cf8 100644
--- a/src/Utilities/Cryptography/Models/SrpSignup.cs
+++ b/src/Utilities/Cryptography/Models/SrpSignup.cs
@@ -15,35 +15,35 @@ public class SrpSignup
///
/// Initializes a new instance of the class with the specified salt, private key, and verifier.
///
- /// The email address.
+ /// The username.
/// The salt value.
/// The private key value.
/// The verifier value.
- public SrpSignup(string email, string salt, string privateKey, string verifier)
+ public SrpSignup(string username, string salt, string privateKey, string verifier)
{
- Email = email;
+ Username = username.ToLowerInvariant().Trim();
Salt = salt;
PrivateKey = privateKey;
Verifier = verifier;
}
///
- /// Gets or sets the email value.
+ /// Gets the username value.
///
- public string Email { get; set; }
+ public string Username { get; }
///
- /// Gets or sets the salt value.
+ /// Gets the salt value.
///
- public string Salt { get; set; }
+ public string Salt { get; }
///
- /// Gets or sets the private key value.
+ /// Gets the private key value.
///
- public string PrivateKey { get; set; }
+ public string PrivateKey { get; }
///
- /// Gets or sets the verifier value.
+ /// Gets the verifier value.
///
- public string Verifier { get; set; }
+ public string Verifier { get; }
}
diff --git a/src/Utilities/Cryptography/Srp.cs b/src/Utilities/Cryptography/Srp.cs
index af164f5eb..2c2258605 100644
--- a/src/Utilities/Cryptography/Srp.cs
+++ b/src/Utilities/Cryptography/Srp.cs
@@ -21,31 +21,31 @@ public static class Srp
///
/// SrpClient.
/// Salt.
- /// Email.
+ /// Username.
/// Hashed password string.
/// SrpSignup model.
- public static SrpSignup SignupPrepareAsync(SrpClient client, string salt, string email, string passwordHashString)
+ public static SrpSignup SignupPrepareAsync(SrpClient client, string salt, string username, string passwordHashString)
{
// Derive a key from the password using Argon2id
// Signup: client generates a salt and verifier.
- var privateKey = DerivePrivateKey(salt, email, passwordHashString);
+ var privateKey = DerivePrivateKey(salt, username, passwordHashString);
var verifier = client.DeriveVerifier(privateKey);
- return new SrpSignup(email, salt, privateKey, verifier);
+ return new SrpSignup(username, salt, privateKey, verifier);
}
///
/// Derive a private key for a user.
///
/// Salt.
- /// Email.
+ /// Username.
/// Hashed password string.
/// Private key as string.
- public static string DerivePrivateKey(string salt, string email, string passwordHashString)
+ public static string DerivePrivateKey(string salt, string username, string passwordHashString)
{
var client = new SrpClient();
- return client.DerivePrivateKey(salt, email, passwordHashString);
+ return client.DerivePrivateKey(salt, username, passwordHashString);
}
///
@@ -76,16 +76,16 @@ public static class Srp
/// Client ephemeral secret.
/// Server public ephemeral.
/// Salt.
- /// Email.
+ /// Username.
/// session.
- public static SrpSession DeriveSessionClient(string privateKey, string clientSecretEphemeral, string serverEphemeralPublic, string salt, string email)
+ public static SrpSession DeriveSessionClient(string privateKey, string clientSecretEphemeral, string serverEphemeralPublic, string salt, string username)
{
var client = new SrpClient();
return client.DeriveSession(
clientSecretEphemeral,
serverEphemeralPublic,
salt,
- email,
+ username,
privateKey);
}
@@ -95,18 +95,18 @@ public static class Srp
/// serverEphemeralSecret.
/// clientEphemeralPublic.
/// Salt.
- /// Email.
+ /// Username.
/// Verifier.
/// Client session proof.
/// SrpSession.
- public static SrpSession DeriveSessionServer(string serverEphemeralSecret, string clientEphemeralPublic, string salt, string email, string verifier, string clientSessionProof)
+ public static SrpSession DeriveSessionServer(string serverEphemeralSecret, string clientEphemeralPublic, string salt, string username, string verifier, string clientSessionProof)
{
var server = new SrpServer();
return server.DeriveSession(
serverEphemeralSecret,
clientEphemeralPublic,
salt,
- email,
+ username,
verifier,
clientSessionProof);
}