mirror of
https://github.com/bitwarden/server
synced 2025-12-16 00:03:54 +00:00
* Add checksum to Login Uri models
* Revert "Revert "Add checksum to Login Uri models (#3318)" (#3417)"
This reverts commit b44887d125.
* PM-4810 Bumped up minimum version
---------
Co-authored-by: Carlos Gonçalves <cgoncalves@bitwarden.com>
Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
Co-authored-by: Carlos Gonçalves <carlosmaccam@gmail.com>
95 lines
2.6 KiB
C#
95 lines
2.6 KiB
C#
using Bit.Core.Enums;
|
|
using Bit.Core.Utilities;
|
|
using Bit.Core.Vault.Models.Data;
|
|
|
|
namespace Bit.Api.Vault.Models;
|
|
|
|
public class CipherLoginModel
|
|
{
|
|
public CipherLoginModel() { }
|
|
|
|
public CipherLoginModel(CipherLoginData data)
|
|
{
|
|
Uris = data.Uris?.Select(u => new CipherLoginUriModel(u))?.ToList();
|
|
if (!Uris?.Any() ?? true)
|
|
{
|
|
Uri = data.Uri;
|
|
}
|
|
|
|
if (data.Fido2Credentials != null)
|
|
{
|
|
Fido2Credentials = data.Fido2Credentials.Select(key => new CipherFido2CredentialModel(key)).ToArray();
|
|
}
|
|
|
|
Username = data.Username;
|
|
Password = data.Password;
|
|
PasswordRevisionDate = data.PasswordRevisionDate;
|
|
Totp = data.Totp;
|
|
AutofillOnPageLoad = data.AutofillOnPageLoad;
|
|
}
|
|
|
|
[EncryptedString]
|
|
[EncryptedStringLength(10000)]
|
|
public string Uri
|
|
{
|
|
get => Uris?.FirstOrDefault()?.Uri;
|
|
set
|
|
{
|
|
if (string.IsNullOrWhiteSpace(value))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (Uris == null)
|
|
{
|
|
Uris = new List<CipherLoginUriModel>();
|
|
}
|
|
|
|
Uris.Add(new CipherLoginUriModel(value));
|
|
}
|
|
}
|
|
public List<CipherLoginUriModel> Uris { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(1000)]
|
|
public string Username { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(5000)]
|
|
public string Password { get; set; }
|
|
public DateTime? PasswordRevisionDate { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(1000)]
|
|
public string Totp { get; set; }
|
|
public bool? AutofillOnPageLoad { get; set; }
|
|
public CipherFido2CredentialModel[] Fido2Credentials { get; set; }
|
|
|
|
public class CipherLoginUriModel
|
|
{
|
|
public CipherLoginUriModel() { }
|
|
|
|
public CipherLoginUriModel(string uri)
|
|
{
|
|
Uri = uri;
|
|
}
|
|
|
|
public CipherLoginUriModel(CipherLoginData.CipherLoginUriData uri)
|
|
{
|
|
Uri = uri.Uri;
|
|
UriChecksum = uri.UriChecksum;
|
|
Match = uri.Match;
|
|
}
|
|
|
|
[EncryptedString]
|
|
[EncryptedStringLength(10000)]
|
|
public string Uri { get; set; }
|
|
[EncryptedString]
|
|
[EncryptedStringLength(10000)]
|
|
public string UriChecksum { get; set; }
|
|
public UriMatchType? Match { get; set; } = null;
|
|
|
|
public CipherLoginData.CipherLoginUriData ToCipherLoginUriData()
|
|
{
|
|
return new CipherLoginData.CipherLoginUriData { Uri = Uri, UriChecksum = UriChecksum, Match = Match, };
|
|
}
|
|
}
|
|
}
|