| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.ExternalAuthentication.Constants; |
| | | 3 | | using Elsa.ExternalAuthentication.Services; |
| | | 4 | | using FastEndpoints; |
| | | 5 | | using Microsoft.AspNetCore.Builder; |
| | | 6 | | using Microsoft.AspNetCore.RateLimiting; |
| | | 7 | | |
| | | 8 | | namespace Elsa.ExternalAuthentication.Endpoints.Broker; |
| | | 9 | | |
| | 7 | 10 | | internal sealed class CompleteLogout(IExternalAuthenticationBroker broker) : ElsaEndpoint<CompleteLogoutRequest> |
| | | 11 | | { |
| | | 12 | | public override void Configure() |
| | | 13 | | { |
| | 6 | 14 | | Get("/external-authentication/logout/callback/{connectionKey}"); |
| | 6 | 15 | | AllowAnonymous(); |
| | 12 | 16 | | Options(x => x.RequireRateLimiting(ExternalAuthenticationRateLimitPolicyNames.ProviderCallback)); |
| | 6 | 17 | | } |
| | | 18 | | |
| | | 19 | | public override async Task HandleAsync(CompleteLogoutRequest request, CancellationToken cancellationToken) |
| | | 20 | | { |
| | 1 | 21 | | var result = await broker.CompleteLogoutAsync(Route<string>("connectionKey") ?? request.ConnectionKey ?? string. |
| | 1 | 22 | | if (result.Error is { } error) |
| | | 23 | | { |
| | 0 | 24 | | await BrokerEndpointSupport.SendErrorAsync(Send, error, cancellationToken); |
| | 0 | 25 | | return; |
| | | 26 | | } |
| | | 27 | | |
| | 1 | 28 | | await Send.RedirectAsync(result.RedirectUri!.ToString(), false, true); |
| | 1 | 29 | | } |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | internal sealed class CompleteLogoutRequest |
| | | 33 | | { |
| | | 34 | | public string? ConnectionKey { get; set; } |
| | | 35 | | public string? State { get; set; } |
| | | 36 | | } |