// 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 OnGet() { var localAddresses = new List { "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(); } } }