From 16a579d7fa10fcab2c76ad57be049fa82ce5b99f Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Tue, 26 Sep 2017 09:59:13 +0100 Subject: [PATCH 1/9] !wip added base url field in Ombi Settings #1513 --- .../Settings/Models/OmbiSettings.cs | 2 +- .../ClientApp/app/interfaces/ISettings.ts | 2 +- .../app/settings/ombi/ombi.component.html | 10 +++++++- .../app/settings/ombi/ombi.component.ts | 1 + src/Ombi/Startup.cs | 10 +++----- src/Ombi/TagHelpers/ReverseProxyTagHelper.cs | 24 +++++++++++++++++++ src/Ombi/Views/Shared/_Layout.cshtml | 4 ++-- src/Ombi/Views/_ViewImports.cshtml | 2 +- 8 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 src/Ombi/TagHelpers/ReverseProxyTagHelper.cs diff --git a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs index da13109b0..9cacbd8e2 100644 --- a/src/Ombi.Settings/Settings/Models/OmbiSettings.cs +++ b/src/Ombi.Settings/Settings/Models/OmbiSettings.cs @@ -2,7 +2,7 @@ { public class OmbiSettings : Models.Settings { - //public string BaseUrl { get; set; } + public string BaseUrl { get; set; } public bool CollectAnalyticData { get; set; } public bool Wizard { get; set; } public string ApiKey { get; set; } diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index e4bb69391..2dfcdad32 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -9,7 +9,7 @@ export interface IExternalSettings extends ISettings { export interface IOmbiSettings extends ISettings { port: number; - //baseUrl:string, + baseUrl: string; collectAnalyticData: boolean; wizard: boolean; apiKey: string; diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html index f3a8d5053..ac2d05ac5 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.html @@ -20,7 +20,7 @@ --> - +
Allow media server users to authenticate
+ +
+ +
+ +
+
@@ -56,5 +63,6 @@
+ \ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts index 49075a1dc..b481dd1bd 100644 --- a/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts +++ b/src/Ombi/ClientApp/app/settings/ombi/ombi.component.ts @@ -23,6 +23,7 @@ export class OmbiComponent implements OnInit { apiKey: [x.apiKey], externalUrl: [x.externalUrl], allowExternalUsersToAuthenticate: [x.allowExternalUsersToAuthenticate], + baseUrl: [x.baseUrl], }); }); } diff --git a/src/Ombi/Startup.cs b/src/Ombi/Startup.cs index 1aca98b63..9fd750da9 100644 --- a/src/Ombi/Startup.cs +++ b/src/Ombi/Startup.cs @@ -45,7 +45,7 @@ using Swashbuckle.AspNetCore.Swagger; namespace Ombi { - public partial class Startup + public class Startup { public Startup(IHostingEnvironment env) { @@ -167,7 +167,7 @@ namespace Ombi app.UseAuthentication(); - //ApiKeyMiddlewear(app, serviceProvider); + ApiKeyMiddlewear(app, serviceProvider); app.UseSwagger(); app.UseSwaggerUI(c => { @@ -210,11 +210,7 @@ namespace Ombi else { var identity = new GenericIdentity("API"); - identity.AddClaim(new System.Security.Claims.Claim("Origin", "Api")); - identity.AddClaim(new System.Security.Claims.Claim("role", "Admin")); - - var principal = new GenericPrincipal(identity, new[] { "ApiUser" }); - // TODO need to think about if I require a JWT Token here. + var principal = new GenericPrincipal(identity, new[] {"Admin", "ApiUser"}); context.User = principal; await next(); } diff --git a/src/Ombi/TagHelpers/ReverseProxyTagHelper.cs b/src/Ombi/TagHelpers/ReverseProxyTagHelper.cs new file mode 100644 index 000000000..684fd036e --- /dev/null +++ b/src/Ombi/TagHelpers/ReverseProxyTagHelper.cs @@ -0,0 +1,24 @@ +using Microsoft.AspNetCore.Razor.TagHelpers; +using Ombi.Core.Settings; +using Ombi.Settings.Settings.Models; + +namespace Ombi.TagHelpers +{ + public class ReverseProxyTagHelper : TagHelper + { + public ReverseProxyTagHelper(ISettingsService c) + { + _ctx = c; + } + + private readonly ISettingsService _ctx; + + public override void Process(TagHelperContext context, TagHelperOutput output) + { + output.TagName = "base"; + var s = _ctx.GetSettings(); + var baseUrl = string.IsNullOrEmpty(s.BaseUrl) ? "/" : s.BaseUrl; + output.Attributes.SetAttribute("href", baseUrl); + } + } +} diff --git a/src/Ombi/Views/Shared/_Layout.cshtml b/src/Ombi/Views/Shared/_Layout.cshtml index a42776fe3..07fd0f503 100644 --- a/src/Ombi/Views/Shared/_Layout.cshtml +++ b/src/Ombi/Views/Shared/_Layout.cshtml @@ -4,13 +4,13 @@ Ombi - + @**@ + - @RenderBody() diff --git a/src/Ombi/Views/_ViewImports.cshtml b/src/Ombi/Views/_ViewImports.cshtml index 13274f512..99def46c2 100644 --- a/src/Ombi/Views/_ViewImports.cshtml +++ b/src/Ombi/Views/_ViewImports.cshtml @@ -1,4 +1,4 @@ @using Ombi @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" @addTagHelper "*, Microsoft.AspNetCore.SpaServices" -@*@addTagHelper *, MiniProfiler.AspNetCore.Mvc*@ \ No newline at end of file +@addTagHelper *, Ombi \ No newline at end of file From e51d9571691675a19b2d915cc2c5031f6a6bfa54 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Tue, 26 Sep 2017 13:09:44 +0100 Subject: [PATCH 2/9] !wip Moved the about tab under the system dropdown #1513 --- src/Ombi/ClientApp/app/settings/settingsmenu.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index 3a5048468..813b8c49d 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -1,6 +1,5 @@