aboutsummaryrefslogtreecommitdiff
path: root/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets
diff options
context:
space:
mode:
Diffstat (limited to 'docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets')
-rw-r--r--docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs2
-rw-r--r--docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs14
2 files changed, 14 insertions, 2 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
index 8b9420a..1f00f9a 100644
--- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
+++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretInfo.cs
@@ -8,7 +8,7 @@ public class SecretInfo
{
[Column(NotNull = true)]
public string Key { get; set; } = default!;
- [Column(NotNull = true, Generated = true, NoUpdate = true, ActAsKey = true)]
+ [Column(NotNull = true, NoUpdate = true, ActAsKey = true)]
public string Secret { get; set; } = default!;
[Column(DefaultEmptyForString = true)]
public string Description { get; set; } = default!;
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs
index fc13707..4d9b14c 100644
--- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs
+++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Secrets/SecretService.cs
@@ -1,4 +1,3 @@
-using CrupestApi.Commons;
using CrupestApi.Commons.Crud;
namespace CrupestApi.Commons.Secrets;
@@ -11,6 +10,19 @@ public class SecretService : CrudService<SecretInfo>, ISecretService
}
+ protected override void DoInitializeDatabase(System.Data.IDbConnection connection)
+ {
+ base.DoInitializeDatabase(connection);
+ using var transaction = connection.BeginTransaction();
+ _table.Insert(connection, new SecretInfo
+ {
+ Key = SecretsConstants.SecretManagementKey,
+ Secret = "crupest",
+ Description = "This is the init key. Please revoke it immediately after creating a new one."
+ });
+ transaction.Commit();
+ }
+
public List<string> GetPermissions(string secret)
{
var list = _table.Select<SecretInfo>(_dbConnection,