!wip added base url field in Ombi Settings #1513

pull/1520/head
Jamie.Rees 7 years ago
parent ccb1bd30d0
commit 16a579d7fa

@ -2,7 +2,7 @@
{ {
public class OmbiSettings : Models.Settings public class OmbiSettings : Models.Settings
{ {
//public string BaseUrl { get; set; } public string BaseUrl { get; set; }
public bool CollectAnalyticData { get; set; } public bool CollectAnalyticData { get; set; }
public bool Wizard { get; set; } public bool Wizard { get; set; }
public string ApiKey { get; set; } public string ApiKey { get; set; }

@ -9,7 +9,7 @@ export interface IExternalSettings extends ISettings {
export interface IOmbiSettings extends ISettings { export interface IOmbiSettings extends ISettings {
port: number; port: number;
//baseUrl:string, baseUrl: string;
collectAnalyticData: boolean; collectAnalyticData: boolean;
wizard: boolean; wizard: boolean;
apiKey: string; apiKey: string;

@ -20,7 +20,7 @@
<input type="text" class="form-control form-control-custom " id="externalUrl" name="externalUrl" placeholder="http://ombi.io/" formControlName="externalUrl" tooltipPosition="top" pTooltip="This will be the link that will be in any emails/notifications sent to the users."> <input type="text" class="form-control form-control-custom " id="externalUrl" name="externalUrl" placeholder="http://ombi.io/" formControlName="externalUrl" tooltipPosition="top" pTooltip="This will be the link that will be in any emails/notifications sent to the users.">
</div> </div>
</div>--> </div>-->
<div class="col-md-6">
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
<input type="checkbox" id="allowExternalUsersToAuthenticate" allowExternalUsersToAuthenticate="allowExternalUsersToAuthenticate" formControlName="allowExternalUsersToAuthenticate" <input type="checkbox" id="allowExternalUsersToAuthenticate" allowExternalUsersToAuthenticate="allowExternalUsersToAuthenticate" formControlName="allowExternalUsersToAuthenticate"
@ -28,6 +28,13 @@
<label for="allowExternalUsersToAuthenticate">Allow media server users to authenticate</label> <label for="allowExternalUsersToAuthenticate">Allow media server users to authenticate</label>
</div> </div>
</div> </div>
<div class="form-group">
<label for="baseUrl" class="control-label">Base Url</label>
<div>
<input type="text" class="form-control form-control-custom" id="baseUrl" name="baseUrl" placeholder="/ombi" formControlName="baseUrl">
</div>
</div>
<div class="form-group"> <div class="form-group">
<label for="ApiKey" class="control-label">Api Key</label> <label for="ApiKey" class="control-label">Api Key</label>
@ -56,5 +63,6 @@
<button [disabled]="form.invalid" type="submit" id="save" class="btn btn-primary-outline">Submit</button> <button [disabled]="form.invalid" type="submit" id="save" class="btn btn-primary-outline">Submit</button>
</div> </div>
</div> </div>
</div>
</form> </form>
</fieldset> </fieldset>

@ -23,6 +23,7 @@ export class OmbiComponent implements OnInit {
apiKey: [x.apiKey], apiKey: [x.apiKey],
externalUrl: [x.externalUrl], externalUrl: [x.externalUrl],
allowExternalUsersToAuthenticate: [x.allowExternalUsersToAuthenticate], allowExternalUsersToAuthenticate: [x.allowExternalUsersToAuthenticate],
baseUrl: [x.baseUrl],
}); });
}); });
} }

@ -45,7 +45,7 @@ using Swashbuckle.AspNetCore.Swagger;
namespace Ombi namespace Ombi
{ {
public partial class Startup public class Startup
{ {
public Startup(IHostingEnvironment env) public Startup(IHostingEnvironment env)
{ {
@ -167,7 +167,7 @@ namespace Ombi
app.UseAuthentication(); app.UseAuthentication();
//ApiKeyMiddlewear(app, serviceProvider); ApiKeyMiddlewear(app, serviceProvider);
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(c => app.UseSwaggerUI(c =>
{ {
@ -210,11 +210,7 @@ namespace Ombi
else else
{ {
var identity = new GenericIdentity("API"); var identity = new GenericIdentity("API");
identity.AddClaim(new System.Security.Claims.Claim("Origin", "Api")); var principal = new GenericPrincipal(identity, new[] {"Admin", "ApiUser"});
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.
context.User = principal; context.User = principal;
await next(); await next();
} }

@ -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<OmbiSettings> c)
{
_ctx = c;
}
private readonly ISettingsService<OmbiSettings> _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);
}
}
}

@ -4,13 +4,13 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ombi</title> <title>Ombi</title>
<base href="/" /> @*<base href="/ombi" />*@
<Reverse-Proxy></Reverse-Proxy>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="~/loading.css" asp-append-version="true" /> <link rel="stylesheet" href="~/loading.css" asp-append-version="true" />
<link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" /> <link rel="stylesheet" href="~/dist/vendor.css" asp-append-version="true" />
<script src="~/dist/vendor.js" asp-append-version="true" defer></script> <script src="~/dist/vendor.js" asp-append-version="true" defer></script>
<script src="~/dist/main.js" asp-append-version="true" defer></script> <script src="~/dist/main.js" asp-append-version="true" defer></script>
<mini-profiler />
</head> </head>
<body> <body>
@RenderBody() @RenderBody()

@ -1,4 +1,4 @@
@using Ombi @using Ombi
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" @addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers"
@addTagHelper "*, Microsoft.AspNetCore.SpaServices" @addTagHelper "*, Microsoft.AspNetCore.SpaServices"
@*@addTagHelper *, MiniProfiler.AspNetCore.Mvc*@ @addTagHelper *, Ombi
Loading…
Cancel
Save