diff --git a/Clinically.Kinde.Authentication.csproj b/Clinically.Kinde.Authentication.csproj index c132cf4..8bcdbbe 100644 --- a/Clinically.Kinde.Authentication.csproj +++ b/Clinically.Kinde.Authentication.csproj @@ -9,7 +9,7 @@ git https://github.com/clinically-au/kinde-authentication Clinically.Kinde.Authentication - 1.2.2 + 1.2.3 README.md Clinically.Kinde.Authentication Clinically.Kinde.Authentication diff --git a/Identity/KindeIdentityEndpointRouteBuilderExtensions.cs b/Identity/KindeIdentityEndpointRouteBuilderExtensions.cs index 8c5c32c..c30e335 100644 --- a/Identity/KindeIdentityEndpointRouteBuilderExtensions.cs +++ b/Identity/KindeIdentityEndpointRouteBuilderExtensions.cs @@ -42,10 +42,12 @@ public static IEndpointConventionBuilder MapKindeIdentityEndpoints(this IEndpoin accountGroup.MapGet("/LoginCallback", new Func, string?, string?, Task>(async (context, [FromServices] signInManager, - [FromQuery] ReturnUrl, - [FromQuery] RemoteError) => + [FromQuery] returnUrl, + [FromQuery] remoteError) => { - if (RemoteError is not null) + ArgumentException.ThrowIfNullOrEmpty(returnUrl); + + if (remoteError is not null) { return TypedResults.Redirect("/Error"); } @@ -64,7 +66,7 @@ await signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKe return TypedResults.Redirect("/Error"); } - return TypedResults.Redirect(ReturnUrl); + return TypedResults.Redirect(returnUrl); })); accountGroup.MapPost("/Logout", async ( @@ -74,9 +76,9 @@ await signInManager.ExternalLoginSignInAsync(info.LoginProvider, info.ProviderKe [FromForm] string returnUrl) => { await signInManager.SignOutAsync(); - var authority = config.GetRequiredSection("Kinde:Authority").Value; - var baseUrl = config.GetRequiredSection("AppConfig:BaseUrl").Value ?? string.Empty; - var logoutUri = $"{authority}/logout?redirect={Uri.EscapeDataString(baseUrl)}"; + var authority = config.GetRequiredSection("Kinde:Domain").Value; + var baseUrl = config.GetRequiredSection("AppConfig:BaseUrl").Value; + var logoutUri = $"{authority}/logout?redirect={Uri.EscapeDataString(baseUrl!)}"; return TypedResults.Redirect(logoutUri); });