35 lines
1.0 KiB
C#
35 lines
1.0 KiB
C#
// Copyright (c) Duende Software. All rights reserved.
|
|
// See LICENSE in the project root for license information.
|
|
|
|
using Microsoft.AspNetCore.Authentication;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
|
|
|
namespace Microser.IdS.Pages.Diagnostics
|
|
{
|
|
[SecurityHeaders]
|
|
[Authorize]
|
|
public class Index : PageModel
|
|
{
|
|
public ViewModel View { get; set; } = default!;
|
|
|
|
public async Task<IActionResult> OnGet()
|
|
{
|
|
var localAddresses = new List<string?> { "127.0.0.1", "::1" };
|
|
if (HttpContext.Connection.LocalIpAddress != null)
|
|
{
|
|
localAddresses.Add(HttpContext.Connection.LocalIpAddress.ToString());
|
|
}
|
|
|
|
if (!localAddresses.Contains(HttpContext.Connection.RemoteIpAddress?.ToString()))
|
|
{
|
|
return NotFound();
|
|
}
|
|
|
|
View = new ViewModel(await HttpContext.AuthenticateAsync());
|
|
|
|
return Page();
|
|
}
|
|
}
|
|
} |