WIP making ClientCreate endpoint
This commit is contained in:
parent
138f335af0
commit
eb872a4f44
28 changed files with 365 additions and 121 deletions
|
|
@ -11,7 +11,7 @@ public record RealmCreateResponse(Guid Id, string Slug, string Name);
|
|||
|
||||
public class RealmService(
|
||||
Db db,
|
||||
IEncryptionService encryptionService) : IRealmService
|
||||
IKeyProvisioningService keyProvisioningService) : IRealmService
|
||||
{
|
||||
public async Task<Realm?> FindBySlug(string slug, CancellationToken ct = default)
|
||||
{
|
||||
|
|
@ -26,7 +26,7 @@ public class RealmService(
|
|||
Id = request.Id ?? Guid.CreateVersion7(),
|
||||
Slug = request.Slug ?? SlugHelper.GenerateSlug(request.Name),
|
||||
Name = request.Name,
|
||||
Keys = [ CreateKey() ],
|
||||
Keys = [ keyProvisioningService.CreateRsaKey() ],
|
||||
};
|
||||
|
||||
db.Add(realm);
|
||||
|
|
@ -40,21 +40,8 @@ public class RealmService(
|
|||
{
|
||||
await db.Entry(realm).Collection(r => r.Keys)
|
||||
.Query()
|
||||
.Where(k => k.DeactivatedAt == null)
|
||||
.Where(k => k.RevokedAt == null)
|
||||
.LoadAsync();
|
||||
|
||||
}
|
||||
|
||||
private Key CreateKey()
|
||||
{
|
||||
using RSA rsa = RSA.Create(2048);
|
||||
|
||||
Key key = new()
|
||||
{
|
||||
Priority = 10,
|
||||
};
|
||||
key.SetPrivateKey(encryptionService, rsa.ExportPkcs8PrivateKey());
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue