Fix Google login callback routing and forwarded headers
This commit is contained in:
parent
6729f91275
commit
fedb011154
@ -87,7 +87,10 @@ public class AccountController : Controller
|
||||
[ValidateAntiForgeryToken]
|
||||
public IActionResult ExternalLogin(string provider, string? returnUrl = null)
|
||||
{
|
||||
var redirectUrl = Url.Action(nameof(ExternalLoginCallback), new { returnUrl });
|
||||
var redirectUrl = Url.Action(
|
||||
nameof(ExternalLoginCallback),
|
||||
"Account",
|
||||
new { area = string.Empty, returnUrl });
|
||||
var properties = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl);
|
||||
return Challenge(properties, provider);
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using MemberCenter.Application.Abstractions;
|
||||
using MemberCenter.Application.Constants;
|
||||
@ -89,6 +90,13 @@ builder.Services.AddAuthorization(options =>
|
||||
options.AddPolicy("Superuser", policy => policy.RequireRole("superuser"));
|
||||
});
|
||||
|
||||
builder.Services.Configure<ForwardedHeadersOptions>(options =>
|
||||
{
|
||||
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
options.KnownNetworks.Clear();
|
||||
options.KnownProxies.Clear();
|
||||
});
|
||||
|
||||
builder.Services.AddRateLimiter(options =>
|
||||
{
|
||||
options.RejectionStatusCode = StatusCodes.Status429TooManyRequests;
|
||||
@ -154,6 +162,7 @@ if (!app.Environment.IsDevelopment())
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseForwardedHeaders();
|
||||
app.UseRouting();
|
||||
app.UseRateLimiter();
|
||||
app.UseAuthentication();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user