mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 22:11:48 +01:00
Apps: Don't redirect .onion requests to canonical domain (#5776)
Fixes #5729.
This commit is contained in:
parent
c2acff81c6
commit
33d3a25928
1 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using BTCPayServer.Abstractions.Extensions;
|
||||||
using BTCPayServer.Services;
|
using BTCPayServer.Services;
|
||||||
using Microsoft.AspNetCore.Mvc.ActionConstraints;
|
using Microsoft.AspNetCore.Mvc.ActionConstraints;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
@ -25,7 +25,7 @@ namespace BTCPayServer.Filters
|
||||||
{
|
{
|
||||||
var req = context.RouteContext.HttpContext.Request;
|
var req = context.RouteContext.HttpContext.Request;
|
||||||
var policies = context.RouteContext.HttpContext.RequestServices.GetService<PoliciesSettings>();
|
var policies = context.RouteContext.HttpContext.RequestServices.GetService<PoliciesSettings>();
|
||||||
var mapping = policies?.DomainToAppMapping?.ToList() ?? new List<PoliciesSettings.DomainToAppMappingItem>();
|
var mapping = policies?.DomainToAppMapping?.ToList() ?? [];
|
||||||
if (policies is { RootAppId: { } rootAppId, RootAppType: { } rootAppType })
|
if (policies is { RootAppId: { } rootAppId, RootAppType: { } rootAppType })
|
||||||
{
|
{
|
||||||
mapping.Add(new PoliciesSettings.DomainToAppMappingItem
|
mapping.Add(new PoliciesSettings.DomainToAppMappingItem
|
||||||
|
@ -37,7 +37,7 @@ namespace BTCPayServer.Filters
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have an appId, we can redirect to the canonical domain
|
// If we have an appId, we can redirect to the canonical domain
|
||||||
if ((string)context.RouteContext.RouteData.Values["appId"] is string appId)
|
if ((string)context.RouteContext.RouteData.Values["appId"] is { } appId && !req.IsOnion())
|
||||||
{
|
{
|
||||||
var redirectDomain = mapping.FirstOrDefault(item => item.AppId == appId)?.Domain;
|
var redirectDomain = mapping.FirstOrDefault(item => item.AppId == appId)?.Domain;
|
||||||
// App is accessed via path, redirect to canonical domain
|
// App is accessed via path, redirect to canonical domain
|
||||||
|
|
Loading…
Add table
Reference in a new issue