Add tests and fixes to .well-known/openid-configuration and create realm

This commit is contained in:
eelke 2026-02-14 14:50:06 +01:00
parent e07d6e3ea5
commit d440979451
17 changed files with 642 additions and 45 deletions

View file

@ -12,6 +12,11 @@ public class RealmService(
Db db,
IEncryptionService encryptionService) : IRealmService
{
public Task<Realm?> FindBySlug(string slug, CancellationToken ct = default)
{
throw new NotImplementedException();
}
public async Task<Result<RealmCreateResponse>> Create(RealmCreateRequest request, CancellationToken ct = default)
{
Realm realm = new()
@ -19,10 +24,10 @@ public class RealmService(
Id = request.Id ?? Guid.CreateVersion7(),
Slug = request.Slug ?? SlugHelper.GenerateSlug(request.Name),
Name = request.Name,
Keys = [ CreateKey() ],
};
using RSA rsa = RSA.Create(2048);
realm.SetPrivateKey(encryptionService, rsa.ExportPkcs8PrivateKey());
db.Add(realm);
await db.SaveChangesAsync(ct);
@ -30,4 +35,17 @@ public class RealmService(
return new RealmCreateResponse(
realm.Id, realm.Slug, realm.Name);
}
private Key CreateKey()
{
using RSA rsa = RSA.Create(2048);
Key key = new()
{
Priority = 10,
};
key.SetPrivateKey(encryptionService, rsa.ExportPkcs8PrivateKey());
return key;
}
}