1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-23 04:21:05 -05:00

encrypted string length attr

This commit is contained in:
Kyle Spearrin 2018-08-02 08:57:32 -04:00
parent 8393af9afc
commit 14956f6383
11 changed files with 56 additions and 36 deletions

View File

@ -19,22 +19,22 @@ namespace Bit.Core.Models.Api
}
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string CardholderName { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Brand { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Number { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string ExpMonth { get; set; }
[EncryptedString]
[StringLength(1000)]
public string ExpYear { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Code { get; set; }
}
}

View File

@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Api
{
@ -16,9 +17,9 @@ namespace Bit.Core.Models.Api
}
public FieldType Type { get; set; }
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Name { get; set; }
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Value { get; set; }
}
}

View File

@ -31,58 +31,58 @@ namespace Bit.Core.Models.Api
}
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Title { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string FirstName { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string MiddleName { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string LastName { get; set; }
[EncryptedString]
[StringLength(1000)]
public string Address1 { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Address2 { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Address3 { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string City { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string State { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string PostalCode { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Country { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Company { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Email { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Phone { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string SSN { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Username { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string PassportNumber { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string LicenseNumber { get; set; }
}
}

View File

@ -27,7 +27,7 @@ namespace Bit.Core.Models.Api
}
[EncryptedString]
[StringLength(10000)]
[EncryptedStringLength(10000)]
public string Uri
{
get => Uris?.FirstOrDefault()?.Uri;
@ -48,14 +48,14 @@ namespace Bit.Core.Models.Api
}
public List<CipherLoginUriModel> Uris { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Username { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Password { get; set; }
public DateTime? PasswordRevisionDate { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Totp { get; set; }
public class CipherLoginUriModel
@ -74,7 +74,7 @@ namespace Bit.Core.Models.Api
}
[EncryptedString]
[StringLength(10000)]
[EncryptedStringLength(10000)]
public string Uri { get; set; }
public UriMatchType? Match { get; set; } = null;
}

View File

@ -1,6 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using Bit.Core.Models.Data;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Api
{
@ -14,7 +15,8 @@ namespace Bit.Core.Models.Api
LastUsedDate = data.LastUsedDate;
}
[StringLength(2000)]
[EncryptedString]
[EncryptedStringLength(2000)]
[Required]
public string Password { get; set; }
[Required]

View File

@ -22,10 +22,10 @@ namespace Bit.Core.Models.Api
public bool Favorite { get; set; }
[Required]
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Name { get; set; }
[EncryptedString]
[StringLength(10000)]
[EncryptedStringLength(10000)]
public string Notes { get; set; }
public IEnumerable<CipherFieldModel> Fields { get; set; }
public IEnumerable<CipherPasswordHistoryModel> PasswordHistory { get; set; }

View File

@ -11,7 +11,7 @@ namespace Bit.Core.Models.Api
{
[Required]
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Name { get; set; }
public IEnumerable<SelectionReadOnlyRequestModel> Groups { get; set; }

View File

@ -10,7 +10,7 @@ namespace Bit.Core.Models.Api
{
[Required]
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string Name { get; set; }
public Folder ToFolder(Guid userId)

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Models.Api
[Required]
public string Key { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string CollectionName { get; set; }
}
}

View File

@ -27,7 +27,7 @@ namespace Bit.Core.Models.Api
[Range(0, 99)]
public short? AdditionalStorageGb { get; set; }
[EncryptedString]
[StringLength(1000)]
[EncryptedStringLength(1000)]
public string CollectionName { get; set; }
public string Country { get; set; }

View File

@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations;
namespace Bit.Core.Utilities
{
public class EncryptedStringLengthAttribute : StringLengthAttribute
{
public EncryptedStringLengthAttribute(int maximumLength)
: base(maximumLength)
{ }
public override string FormatErrorMessage(string name)
{
return string.Format("The field {0} exceeds the maximum encrypted value length of {1} characters.",
name, MaximumLength);
}
}
}