☠️☠️ Bye bye feedproxy.config ☠️☠️
This commit is contained in:
@@ -12,9 +12,7 @@ namespace Umbraco.Core.IO
|
||||
public static string TinyMceConfig => SystemDirectories.Config + "/tinyMceConfig.config";
|
||||
|
||||
public static string NotFoundhandlersConfig => SystemDirectories.Config + "/404handlers.config";
|
||||
|
||||
public static string FeedProxyConfig => string.Concat(SystemDirectories.Config, "/feedProxy.config");
|
||||
|
||||
|
||||
public static string GetContentCacheXml(IGlobalSettings globalSettings)
|
||||
{
|
||||
switch (globalSettings.LocalTempStorageLocation)
|
||||
|
||||
@@ -14,7 +14,7 @@ function dashboardResource($q, $http, umbRequestHelper) {
|
||||
*
|
||||
* @description
|
||||
* Retrieves the dashboard configuration for a given section
|
||||
*
|
||||
*
|
||||
* @param {string} section Alias of section to retrieve dashboard configuraton for
|
||||
* @returns {Promise} resourcePromise object containing the user array.
|
||||
*
|
||||
@@ -36,7 +36,7 @@ function dashboardResource($q, $http, umbRequestHelper) {
|
||||
*
|
||||
* @description
|
||||
* Retrieves dashboard content from a remote source for a given section
|
||||
*
|
||||
*
|
||||
* @param {string} section Alias of section to retrieve dashboard content for
|
||||
* @returns {Promise} resourcePromise object containing the user array.
|
||||
*
|
||||
@@ -70,10 +70,18 @@ function dashboardResource($q, $http, umbRequestHelper) {
|
||||
"dashboardApiBaseUrl",
|
||||
"GetRemoteDashboardCss",
|
||||
values);
|
||||
},
|
||||
|
||||
getRemoteXmlData: function (site, url) {
|
||||
//build request values with optional params
|
||||
var values = { site: site, url: url };
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"dashboardApiBaseUrl",
|
||||
"GetRemoteXml",
|
||||
values)), "Failed to get remote xml");
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
angular.module('umbraco.services')
|
||||
.factory('helpService', function ($http, $q, umbRequestHelper) {
|
||||
.factory('helpService', function ($http, $q, umbRequestHelper, dashboardResource) {
|
||||
var helpTopics = {};
|
||||
|
||||
var defaultUrl = "https://our.umbraco.com/rss/help";
|
||||
var tvUrl = "https://umbraco.tv/feeds/help";
|
||||
var defaultUrl = "rss/help";
|
||||
var tvUrl = "feeds/help";
|
||||
|
||||
function getCachedHelp(url){
|
||||
if(helpTopics[url]){
|
||||
@@ -17,16 +17,14 @@ angular.module('umbraco.services')
|
||||
helpTopics[url] = data;
|
||||
}
|
||||
|
||||
function fetchUrl(url){
|
||||
function fetchUrl(site, url){
|
||||
var deferred = $q.defer();
|
||||
var found = getCachedHelp(url);
|
||||
|
||||
if(found){
|
||||
deferred.resolve(found);
|
||||
}else{
|
||||
|
||||
var proxyUrl = "dashboard/feedproxy.aspx?url=" + url;
|
||||
$http.get(proxyUrl).then(function(data){
|
||||
dashboardResource.getRemoteXmlData(site, url).then(function (data) {
|
||||
var feed = $(data.data);
|
||||
var topics = [];
|
||||
|
||||
@@ -41,7 +39,12 @@ angular.module('umbraco.services')
|
||||
|
||||
setCachedHelp(topics);
|
||||
deferred.resolve(topics);
|
||||
|
||||
},
|
||||
function (exception) {
|
||||
console.error('ex from remote data', exception);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
@@ -50,12 +53,12 @@ angular.module('umbraco.services')
|
||||
var service = {
|
||||
findHelp: function (args) {
|
||||
var url = service.getUrl(defaultUrl, args);
|
||||
return fetchUrl(url);
|
||||
return fetchUrl('OUR', url);
|
||||
},
|
||||
|
||||
findVideos: function (args) {
|
||||
var url = service.getUrl(tvUrl, args);
|
||||
return fetchUrl(url);
|
||||
return fetchUrl('TV', url);
|
||||
},
|
||||
|
||||
getContextHelpForPage: function (section, tree, baseurl) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
function startUpVideosDashboardController($scope, xmlhelper, $log, $http) {
|
||||
function startUpVideosDashboardController($scope, dashboardResource) {
|
||||
$scope.videos = [];
|
||||
$scope.init = function(url){
|
||||
var proxyUrl = "dashboard/feedproxy.aspx?url=" + url;
|
||||
$http.get(proxyUrl).then(function(data){
|
||||
var feed = $(data.data);
|
||||
|
||||
dashboardResource.getRemoteXmlData('COM', url).then(function (data) {
|
||||
var feed = $(data.data);
|
||||
$('item', feed).each(function (i, item) {
|
||||
var video = {};
|
||||
video.thumbnail = $(item).find('thumbnail').attr('url');
|
||||
@@ -11,6 +11,10 @@ function startUpVideosDashboardController($scope, xmlhelper, $log, $http) {
|
||||
video.link = $("guid", item).text();
|
||||
$scope.videos.push(video);
|
||||
});
|
||||
|
||||
},
|
||||
function (exception) {
|
||||
console.error('ex from remote data', exception);
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -24,7 +28,7 @@ function startUpDynamicContentController($timeout, $scope, dashboardResource, as
|
||||
|
||||
vm.loading = true;
|
||||
vm.showDefault = false;
|
||||
|
||||
|
||||
vm.startTour = startTour;
|
||||
|
||||
function onInit() {
|
||||
@@ -93,7 +97,7 @@ function startUpDynamicContentController($timeout, $scope, dashboardResource, as
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
//proxy remote css through the local server
|
||||
assetsService.loadCss(dashboardResource.getRemoteDashboardCssUrl("content"), $scope);
|
||||
dashboardResource.getRemoteDashboardContent("content").then(
|
||||
@@ -117,7 +121,7 @@ function startUpDynamicContentController($timeout, $scope, dashboardResource, as
|
||||
vm.showDefault = true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
onInit();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="row-fluid"
|
||||
ng-init="init('https://umbraco.com/feeds/videos/members')"
|
||||
<div class="row-fluid"
|
||||
ng-init="init('feeds/videos/members')"
|
||||
ng-controller="Umbraco.Dashboard.StartupVideosController">
|
||||
|
||||
<umb-box>
|
||||
@@ -8,7 +8,7 @@
|
||||
<p>Want to master Umbraco? Spend a couple of minutes learning some best practices by watching one of these videos about using Umbraco. And visit <a href="https://umbraco.tv" target="_blank">umbraco.tv</a> for even more Umbraco videos</p>
|
||||
</umb-box-content>
|
||||
</umb-box>
|
||||
|
||||
|
||||
<div ng-show="videos.length">
|
||||
<h4>To get you started:</h4>
|
||||
<ul class="thumbnails" >
|
||||
|
||||
@@ -212,9 +212,6 @@
|
||||
<None Include="Config\scripting.Release.config">
|
||||
<DependentUpon>scripting.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Config\feedProxy.Release.config">
|
||||
<DependentUpon>feedProxy.config</DependentUpon>
|
||||
</None>
|
||||
<None Include="Config\Dashboard.Release.config">
|
||||
<DependentUpon>Dashboard.config</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -236,7 +233,6 @@
|
||||
<Content Include="Umbraco\Config\Lang\ru.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\zh.xml" />
|
||||
<Content Include="Umbraco\Config\Lang\ko.xml" />
|
||||
<Content Include="Umbraco\Dashboard\FeedProxy.aspx" />
|
||||
<Content Include="Umbraco\Config\Lang\da.xml">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
@@ -255,7 +251,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="Config\scripting.config" />
|
||||
<Content Include="Config\feedProxy.config" />
|
||||
<Content Include="Umbraco\Views\Default.cshtml" />
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\EditProfile.cshtml" />
|
||||
<Content Include="Umbraco\PartialViewMacros\Templates\Empty.cshtml" />
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FeedProxy.aspx.cs" Inherits="dashboardUtilities.FeedProxy" %>
|
||||
<%@ OutputCache Duration="1800" VaryByParam="url" %>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<feedProxy>
|
||||
<!-- To enable the FeedProxy to access other domains, please add the hostname to an 'allow' element. -->
|
||||
<!-- <allow host="domain.com" /> -->
|
||||
|
||||
<!-- The following hostnames are used by on the dashboards, please do not delete these. -->
|
||||
<allow host="umbraco.com" />
|
||||
<allow host="umbraco.org" />
|
||||
<allow host="umbraco.tv" />
|
||||
<allow host="our.umbraco.org" />
|
||||
<allow host="our.umbraco.com" />
|
||||
</feedProxy>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<feedProxy>
|
||||
<!-- To enable the FeedProxy to access other domains, please add the hostname to an 'allow' element. -->
|
||||
<!-- <allow host="domain.com" /> -->
|
||||
|
||||
<!-- The following hostnames are used by on the dashboards, please do not delete these. -->
|
||||
<allow host="umbraco.com" />
|
||||
<allow host="umbraco.org" />
|
||||
<allow host="umbraco.tv" />
|
||||
<allow host="our.umbraco.org" />
|
||||
<allow host="our.umbraco.com" />
|
||||
</feedProxy>
|
||||
@@ -79,7 +79,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Logger.Error<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard content from '{Url}'", url);
|
||||
Logger.Error<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard content from {Url}", url);
|
||||
|
||||
//it's still new JObject() - we return it like this to avoid error codes which triggers UI warnings
|
||||
AppCaches.RuntimeCache.InsertCacheItem<JObject>(key, () => result, new TimeSpan(0, 5, 0));
|
||||
@@ -117,7 +117,7 @@ namespace Umbraco.Web.Editors
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Logger.Error<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard CSS from '{Url}'", url);
|
||||
Logger.Error<DashboardController>(ex.InnerException ?? ex, "Error getting dashboard CSS from {Url}", url);
|
||||
|
||||
//it's still string.Empty - we return it like this to avoid error codes which triggers UI warnings
|
||||
AppCaches.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 5, 0));
|
||||
@@ -130,6 +130,75 @@ namespace Umbraco.Web.Editors
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<HttpResponseMessage> GetRemoteXml(string site, string url)
|
||||
{
|
||||
// This is used in place of the old feedproxy.config
|
||||
// Which was used to grab data from our.umbraco.com, umbraco.com or umbraco.tv
|
||||
// for certain dashboards or the help drawer
|
||||
var urlPrefix = string.Empty;
|
||||
switch (site.ToUpper())
|
||||
{
|
||||
case "TV":
|
||||
urlPrefix = "https://umbraco.tv/";
|
||||
break;
|
||||
|
||||
case "OUR":
|
||||
urlPrefix = "https://our.umbraco.org/";
|
||||
break;
|
||||
|
||||
case "COM":
|
||||
urlPrefix = "https://umbraco.com/";
|
||||
break;
|
||||
|
||||
default:
|
||||
//Throw error
|
||||
return new HttpResponseMessage(HttpStatusCode.Unauthorized)
|
||||
{
|
||||
Content = new StringContent($"The Site {site} and {url} is not on the whitelist"),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
//Make remote call to fetch videos or remote dashboard feed data
|
||||
var key = $"umbraco-XML-feed-{site}-{url.ToCleanString(Core.Strings.CleanStringType.UrlSegment)}";
|
||||
|
||||
var content = AppCaches.RuntimeCache.GetCacheItem<string>(key);
|
||||
var result = string.Empty;
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
result = content;
|
||||
}
|
||||
else
|
||||
{
|
||||
//content is null, go get it
|
||||
try
|
||||
{
|
||||
//fetch remote css
|
||||
content = await HttpClient.GetStringAsync($"{urlPrefix}{url}");
|
||||
|
||||
//can't use content directly, modified closure problem
|
||||
result = content;
|
||||
|
||||
//save server content for 30 mins
|
||||
AppCaches.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 30, 0));
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Logger.Error<DashboardController>(ex.InnerException ?? ex, "Error getting remote dashboard data from {UrlPrefix}{Url}", urlPrefix, url);
|
||||
|
||||
//it's still string.Empty - we return it like this to avoid error codes which triggers UI warnings
|
||||
AppCaches.RuntimeCache.InsertCacheItem<string>(key, () => result, new TimeSpan(0, 5, 0));
|
||||
}
|
||||
}
|
||||
|
||||
return new HttpResponseMessage(HttpStatusCode.OK)
|
||||
{
|
||||
Content = new StringContent(result, Encoding.UTF8, "text/xml")
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
[ValidateAngularAntiForgeryToken]
|
||||
[OutgoingEditorModelEvent]
|
||||
public IEnumerable<Tab<DashboardControl>> GetDashboard(string section)
|
||||
|
||||
@@ -1194,13 +1194,6 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx.designer.cs">
|
||||
<DependentUpon>FeedProxy.aspx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UmbracoApplication.cs" />
|
||||
<Compile Include="UmbracoContext.cs" />
|
||||
<Compile Include="UmbracoInjectedModule.cs" />
|
||||
@@ -1240,7 +1233,6 @@
|
||||
<EmbeddedResource Include="UI\JavaScript\PreviewInitialize.js" />
|
||||
<!--<Content Include="umbraco.presentation\umbraco\users\PermissionEditor.aspx" />-->
|
||||
<Content Include="PublishedCache\NuCache\notes.txt" />
|
||||
<Content Include="umbraco.presentation\umbraco\dashboard\FeedProxy.aspx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Web References\org.umbraco.update\checkforupgrade.disco" />
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FeedProxy.aspx.cs" Inherits="dashboardUtilities.FeedProxy" %>
|
||||
<%@ OutputCache Duration="1800" VaryByParam="url" %>
|
||||
@@ -1,65 +0,0 @@
|
||||
using System.Net.Http;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Web;
|
||||
using Umbraco.Web.UI.Pages;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Xml;
|
||||
using Umbraco.Web.Composing;
|
||||
|
||||
namespace dashboardUtilities
|
||||
{
|
||||
|
||||
|
||||
public partial class FeedProxy : UmbracoEnsuredPage
|
||||
{
|
||||
private static HttpClient _httpClient;
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Request.QueryString.AllKeys.Contains("url") == false || Request.QueryString["url"] == null)
|
||||
return;
|
||||
|
||||
var url = Request.QueryString["url"];
|
||||
if (string.IsNullOrWhiteSpace(url) || url.StartsWith("/"))
|
||||
return;
|
||||
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out var requestUri) == false)
|
||||
return;
|
||||
|
||||
var feedProxyXml = XmlHelper.OpenAsXmlDocument(IOHelper.MapPath(SystemFiles.FeedProxyConfig));
|
||||
if (feedProxyXml?.SelectSingleNode($"//allow[@host = '{requestUri.Host}']") != null && (requestUri.Port == 80 || requestUri.Port == 443))
|
||||
{
|
||||
if (_httpClient == null)
|
||||
_httpClient = new HttpClient();
|
||||
|
||||
using (var request = new HttpRequestMessage(HttpMethod.Get, requestUri))
|
||||
{
|
||||
var response = _httpClient.SendAsync(request).Result;
|
||||
var result = response.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
return;
|
||||
|
||||
Response.Clear();
|
||||
Response.ContentType = Request.CleanForXss("type") ?? MediaTypeNames.Text.Xml;
|
||||
Response.Write(result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Current.Logger.Debug<FeedProxy>("Access to unallowed feedproxy attempted: {RequestUrl}", requestUri);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Current.Logger.Error<FeedProxy>(ex, "Exception occurred");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace dashboardUtilities {
|
||||
|
||||
|
||||
public partial class FeedProxy {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user