New project file, added Aspire, moved security

This commit is contained in:
James Wampler
2026-06-03 18:44:48 -07:00
parent 4c6df1f037
commit d3b36956e4
78 changed files with 2786 additions and 21210 deletions

View File

@@ -1,46 +0,0 @@
using MicCheck.Api.Authorization;
namespace MicCheck.Api.ApiKeys;
public static class ApiKeyEndpoints
{
public static void MapApiKeyEndpoints(this WebApplication app)
{
var group = app
.MapGroup("/api/v1/organisations/{organizationId:int}/api-keys")
.RequireAuthorization(AuthorizationPolicies.OrganizationAdmin)
.WithTags("ApiKeys");
group.MapPost("/", async (
int organizationId,
CreateApiKeyRequest request,
ApiKeyService apiKeyService,
CancellationToken ct) =>
{
var (key, rawKey) = await apiKeyService.CreateAsync(
organizationId, request.Name, request.ExpiresAt, ct);
return Results.Ok(new CreateApiKeyResponse(key.Id, key.Name, rawKey, key.Prefix, key.ExpiresAt));
}).WithName("CreateApiKey");
group.MapGet("/", async (
int organizationId,
ApiKeyService apiKeyService,
CancellationToken ct) =>
{
var keys = await apiKeyService.ListAsync(organizationId, ct);
return Results.Ok(keys.Select(k =>
new ApiKeyResponse(k.Id, k.Name, k.Prefix, k.IsActive, k.ExpiresAt, k.CreatedAt)));
}).WithName("ListApiKeys");
group.MapDelete("/{keyId:int}", async (
int organizationId,
int keyId,
ApiKeyService apiKeyService,
CancellationToken ct) =>
{
await apiKeyService.RevokeAsync(organizationId, keyId, ct);
return Results.NoContent();
}).WithName("RevokeApiKey");
}
}