diff --git a/src/Ombi.Core/Authentication/OmbiUserManager.cs b/src/Ombi.Core/Authentication/OmbiUserManager.cs index 4a0ff0d22..522ffb899 100644 --- a/src/Ombi.Core/Authentication/OmbiUserManager.cs +++ b/src/Ombi.Core/Authentication/OmbiUserManager.cs @@ -37,6 +37,7 @@ using Ombi.Api.Plex.Models; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using Ombi.Helpers; +using Ombi.Settings.Settings.Models; using Ombi.Store.Entities; namespace Ombi.Core.Authentication @@ -47,20 +48,36 @@ namespace Ombi.Core.Authentication IPasswordHasher passwordHasher, IEnumerable> userValidators, IEnumerable> passwordValidators, ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger> logger, IPlexApi plexApi, - IEmbyApi embyApi, ISettingsService embySettings) + IEmbyApi embyApi, ISettingsService embySettings, ISettingsService auth) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger) { _plexApi = plexApi; _embyApi = embyApi; _embySettings = embySettings; + _authSettings = auth; } private readonly IPlexApi _plexApi; private readonly IEmbyApi _embyApi; private readonly ISettingsService _embySettings; + private readonly ISettingsService _authSettings; public override async Task CheckPasswordAsync(OmbiUser user, string password) { + var authSettings = await _authSettings.GetSettingsAsync(); + if (authSettings.AllowNoPassword) + { + // Check their roles + var roles = await GetRolesAsync(user); + if (roles.Contains(OmbiRoles.Admin) || roles.Contains(OmbiRoles.PowerUser)) + { + // Do nothing, let it continue to check the password + } + else + { + return true; + } + } if (user.UserType == UserType.LocalUser) { return await base.CheckPasswordAsync(user, password); diff --git a/src/Ombi.Settings/Settings/Models/AuthenticationSettings.cs b/src/Ombi.Settings/Settings/Models/AuthenticationSettings.cs index 7c2725ec5..b187e1b95 100644 --- a/src/Ombi.Settings/Settings/Models/AuthenticationSettings.cs +++ b/src/Ombi.Settings/Settings/Models/AuthenticationSettings.cs @@ -4,13 +4,7 @@ namespace Ombi.Settings.Settings.Models { public class AuthenticationSettings { - /// - /// This determins if Plex and/or Emby users can log into Ombi - /// - /// - /// true if [allow external users to authenticate]; otherwise, false. - /// - public bool AllowExternalUsersToAuthenticate { get; set; } + public bool AllowNoPassword { get; set; } // Password Options public bool RequireDigit { get; set; } diff --git a/src/Ombi/ClientApp/app/interfaces/ISettings.ts b/src/Ombi/ClientApp/app/interfaces/ISettings.ts index b2e81de89..4f3058f4e 100644 --- a/src/Ombi/ClientApp/app/interfaces/ISettings.ts +++ b/src/Ombi/ClientApp/app/interfaces/ISettings.ts @@ -122,7 +122,7 @@ export interface IJobSettings { } export interface IAuthenticationSettings extends ISettings { - allowExternalUsersToAuthenticate: boolean; + allowNoPassword: boolean; // Password requiredDigit: boolean; diff --git a/src/Ombi/ClientApp/app/login/login.component.ts b/src/Ombi/ClientApp/app/login/login.component.ts index a75ca7348..4f12bba03 100644 --- a/src/Ombi/ClientApp/app/login/login.component.ts +++ b/src/Ombi/ClientApp/app/login/login.component.ts @@ -45,7 +45,7 @@ export class LoginComponent implements OnInit { this.form = this.fb.group({ username: ["", [Validators.required]], - password: ["", [Validators.required]], + password: [""], rememberMe: [false], }); diff --git a/src/Ombi/ClientApp/app/settings/authentication/authentication.component.html b/src/Ombi/ClientApp/app/settings/authentication/authentication.component.html new file mode 100644 index 000000000..394716028 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/authentication/authentication.component.html @@ -0,0 +1,60 @@ + + + +
+ Authentication +
+ +
+ +
+
+ + +
+
+ + + +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/src/Ombi/ClientApp/app/settings/authentication/authentication.component.ts b/src/Ombi/ClientApp/app/settings/authentication/authentication.component.ts new file mode 100644 index 000000000..07346f358 --- /dev/null +++ b/src/Ombi/ClientApp/app/settings/authentication/authentication.component.ts @@ -0,0 +1,45 @@ +import { Component, OnInit } from "@angular/core"; +import { FormBuilder, FormGroup } from "@angular/forms"; + +import { NotificationService } from "../../services"; +import { SettingsService } from "../../services"; + +@Component({ + templateUrl: "./authentication.component.html", +}) +export class AuthenticationComponent implements OnInit { + + public form: FormGroup; + + constructor(private settingsService: SettingsService, + private notificationService: NotificationService, + private fb: FormBuilder) { } + + public ngOnInit() { + this.settingsService.getAuthentication().subscribe(x => { + this.form = this.fb.group({ + allowNoPassword: [x.allowNoPassword], + requiredDigit: [x.requiredDigit], + requiredLength: [x.requiredLength], + requiredLowercase: [x.requiredLowercase], + requireNonAlphanumeric: [x.requireNonAlphanumeric], + requireUppercase: [x.requireUppercase], + }); + }); + } + + public onSubmit(form: FormGroup) { + if (form.invalid) { + this.notificationService.error("Please check your entered values"); + return; + } + + this.settingsService.saveAuthentication(form.value).subscribe(x => { + if (x) { + this.notificationService.success("Successfully saved Authentication settings"); + } else { + this.notificationService.success("There was an error when saving the Authentication settings"); + } + }); + } +} diff --git a/src/Ombi/ClientApp/app/settings/settings.module.ts b/src/Ombi/ClientApp/app/settings/settings.module.ts index 651d0e033..66c1e0888 100644 --- a/src/Ombi/ClientApp/app/settings/settings.module.ts +++ b/src/Ombi/ClientApp/app/settings/settings.module.ts @@ -11,6 +11,7 @@ import { CouchPotatoService, JobService, RadarrService, SonarrService, TesterSer import { PipeModule } from "../pipes/pipe.module"; import { AboutComponent } from "./about/about.component"; +import { AuthenticationComponent } from "./authentication/authentication.component"; import { CouchPotatoComponent } from "./couchpotato/couchpotato.component"; import { CustomizationComponent } from "./customization/customization.component"; import { DogNzbComponent } from "./dognzb/dognzb.component"; @@ -60,6 +61,7 @@ const routes: Routes = [ { path: "Settings/Telegram", component: TelegramComponent, canActivate: [AuthGuard] }, { path: "Settings/Jobs", component: JobsComponent, canActivate: [AuthGuard] }, { path: "Settings/SickRage", component: SickRageComponent, canActivate: [AuthGuard] }, + { path: "Settings/Authentication", component: AuthenticationComponent, canActivate: [AuthGuard] }, ]; @NgModule({ @@ -105,6 +107,7 @@ const routes: Routes = [ DogNzbComponent, SickRageComponent, TelegramComponent, + AuthenticationComponent, ], exports: [ RouterModule, diff --git a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html index 71ad58344..898add18f 100644 --- a/src/Ombi/ClientApp/app/settings/settingsmenu.component.html +++ b/src/Ombi/ClientApp/app/settings/settingsmenu.component.html @@ -10,6 +10,7 @@
  • Customization
  • Landing Page
  • User Importer
  • +
  • Authentication