aboutsummaryrefslogtreecommitdiff
path: root/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
diff options
context:
space:
mode:
Diffstat (limited to 'dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs')
-rw-r--r--dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs48
1 files changed, 0 insertions, 48 deletions
diff --git a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs b/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
deleted file mode 100644
index c3a4de0..0000000
--- a/dropped/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System.Security.Cryptography;
-using System.Text;
-using CrupestApi.Commons.Crud;
-
-namespace CrupestApi.Commons.Secrets;
-
-public class SecretInfo
-{
- [Column(NotNull = true)]
- public string Key { get; set; } = default!;
- [Column(NotNull = true, NoUpdate = true, ActAsKey = true)]
- public string Secret { get; set; } = default!;
- [Column(DefaultEmptyForString = true)]
- public string Description { get; set; } = default!;
- [Column(NotNull = false)]
- public DateTime? ExpireTime { get; set; }
- [Column(NotNull = true, DefaultValue = false)]
- public bool Revoked { get; set; }
- [Column(NotNull = true)]
- public DateTime CreateTime { get; set; }
-
- private static RandomNumberGenerator RandomNumberGenerator = RandomNumberGenerator.Create();
-
- private static string GenerateRandomKey(int length)
- {
- const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- var result = new StringBuilder(length);
- lock (RandomNumberGenerator)
- {
- for (int i = 0; i < length; i++)
- {
- result.Append(chars[RandomNumberGenerator.GetInt32(chars.Length)]);
- }
- }
- return result.ToString();
- }
-
-
- public static string SecretDefaultValueGenerator()
- {
- return GenerateRandomKey(16);
- }
-
- public static DateTime CreateTimeDefaultValueGenerator()
- {
- return DateTime.UtcNow;
- }
-}