Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Pat Hartl
570af4f37c Display error message when redirects don't match 2025-10-18 23:56:34 -05:00

View file

@ -13,6 +13,11 @@ using Serilog;
namespace LANCommander.Server.Startup;
public class AuthenticationFailure
{
public const string CallbackUrlMismatch = "Correlation failed.";
}
public static class Authentication
{
public static WebApplicationBuilder ConfigureAuthentication(this WebApplicationBuilder builder, Settings settings)
@ -94,8 +99,17 @@ public static class Authentication
options.Events.OnRemoteFailure = async context =>
{
context.Response.Redirect("/Login");
Log.Error(context.Failure, "OIDC authentication failed");
switch (context.Failure?.Message)
{
case AuthenticationFailure.CallbackUrlMismatch:
Log.Error(context.Failure, "The identity provider is not configured for the callback URL {CallbackUrl}", $"{context.Request.Scheme}://{context.Request.Host}{context.Request.PathBase}{context.Request.Path}{context.Request.QueryString}");
break;
default:
Log.Error(context.Failure, "OIDC authentication failed");
break;
}
await context.Response.CompleteAsync();
};