using FluentResults; using IdentityShroud.Core.Contracts; using IdentityShroud.Core.Messages.Realm; using IdentityShroud.Core.Model; using IdentityShroud.Core.Services; using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.AspNetCore.Mvc; namespace IdentityShroud.Api; public record ClientCreateReponse(int Id, string ClientId); /// /// The part of the api below realms/{slug}/clients /// public static class ClientApi { public const string ClientGetRouteName = "ClientGet"; public static void MapEndpoints(this IEndpointRouteBuilder erp) { erp.MapPost("", ClientCreate) .Validate() .WithName("ClientCreate") .Produces(StatusCodes.Status201Created); erp.MapGet("{clientId}", ClientGet) .WithName(ClientGetRouteName); } private static Task ClientGet(HttpContext context) { throw new NotImplementedException(); } private static async Task, InternalServerError>> ClientCreate( ClientCreateRequest request, [FromServices] IClientService service, HttpContext context, CancellationToken cancellationToken) { Realm realm = context.GetValidatedRealm(); Result result = await service.Create(realm.Id, request, cancellationToken); // Should i have two set of paths? one for actual REST and one for openid // openid: auth/realms/{realmSlug}/.well-known/openid-configuration // openid: auth/realms/{realmSlug}/openid-connect/(auth|token|jwks) // api: api/v1/realms/{realmId}/.... // api: api/v1/realms/{realmId}/clients/{clientId} //return Results.CreatedAtRoute(ClientGetRouteName, [ "realmSlug" = realmId!?]) throw new NotImplementedException(); } }