| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using Application.Abstractions.Messaging;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Auth;
- /// <summary>
- /// 소셜 로그인 시작 URL 생성 (Naver/Kakao) — 프론트 start 라우트가 state 생성/쿠키 보관 후 호출.
- /// redirectUri 미전달 시 AppSettings OAuth:{Provider}:RedirectUri 사용.
- /// </summary>
- internal sealed class SocialAuthorizeUrl : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapGet("api/auth/{provider}/authorize-url", async (
- string provider,
- ISender sender,
- string? state = null,
- string? redirectUri = null,
- CancellationToken ct = default
- ) => {
- var query = new Application.Features.Api.Auth.SocialAuthorizeUrl.Query(
- provider,
- state ?? string.Empty,
- redirectUri
- );
- var result = await sender.Send(query, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("Auth")
- .AllowAnonymous();
- }
- }
|