From cd2fef0dabed03ca37f813fdecb35463c2cc926b Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 11 Jul 2018 22:40:10 +0900 Subject: [PATCH] Add a error if the browser access BTCPay with the wrong url --- .../Services/BTCPayServerEnvironment.cs | 11 ++++++++++- BTCPayServer/Views/Shared/_Layout.cshtml | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Services/BTCPayServerEnvironment.cs b/BTCPayServer/Services/BTCPayServerEnvironment.cs index a8e5d1105..bdcb187d9 100644 --- a/BTCPayServer/Services/BTCPayServerEnvironment.cs +++ b/BTCPayServer/Services/BTCPayServerEnvironment.cs @@ -7,13 +7,17 @@ using System.Threading.Tasks; using System.Text; using NBXplorer; using NBitcoin; +using Microsoft.AspNetCore.Http; namespace BTCPayServer.Services { public class BTCPayServerEnvironment { - public BTCPayServerEnvironment(IHostingEnvironment env, BTCPayNetworkProvider provider) + public BTCPayServerEnvironment(IHostingEnvironment env, BTCPayNetworkProvider provider, IHttpContextAccessor httpContext) { + ExpectedHost = httpContext.HttpContext.Request.Host.Value; + ExpectedDomain = httpContext.HttpContext.Request.Host.Host; + ExpectedProtocol = httpContext.HttpContext.Request.Scheme; Version = typeof(BTCPayServerEnvironment).GetTypeInfo().Assembly.GetCustomAttribute().Version; #if DEBUG Build = "Debug"; @@ -27,6 +31,11 @@ namespace BTCPayServer.Services { get; set; } + + public string ExpectedDomain { get; set; } + public string ExpectedHost { get; set; } + public string ExpectedProtocol { get; set; } + public NetworkType NetworkType { get; set; } public string Version { diff --git a/BTCPayServer/Views/Shared/_Layout.cshtml b/BTCPayServer/Views/Shared/_Layout.cshtml index 2af9e84cd..98d4d44bf 100644 --- a/BTCPayServer/Views/Shared/_Layout.cshtml +++ b/BTCPayServer/Views/Shared/_Layout.cshtml @@ -78,9 +78,19 @@ + + @RenderBody()