mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 22:03:15 -07:00
feat: allow SSO to create new users automatically
This commit is contained in:
parent
c1271572f1
commit
fcbce72591
5 changed files with 23 additions and 1 deletions
|
@ -15,5 +15,6 @@ namespace Ombi.Settings.Settings.Models
|
|||
public bool EnableOAuth { get; set; } // Plex OAuth
|
||||
public bool EnableHeaderAuth { get; set; } // Header SSO
|
||||
public string HeaderAuthVariable { get; set; } // Header SSO
|
||||
public bool HeaderAuthCreateUser { get; set; } // Header SSO
|
||||
}
|
||||
}
|
|
@ -245,6 +245,7 @@ export interface IAuthenticationSettings extends ISettings {
|
|||
enableOAuth: boolean;
|
||||
enableHeaderAuth: boolean;
|
||||
headerAuthVariable: string;
|
||||
headerAuthCreateUser: boolean;
|
||||
}
|
||||
|
||||
export interface ICustomPage extends ISettings {
|
||||
|
|
|
@ -32,6 +32,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group" *ngIf="form.controls.enableHeaderAuth.value">
|
||||
<div class="checkbox">
|
||||
<mat-slide-toggle id="headerAuthCreateUser" name="headerAuthCreateUser" formControlName="headerAuthCreateUser">SSO creates new users automatically</mat-slide-toggle>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
|
|
|
@ -28,6 +28,7 @@ export class AuthenticationComponent implements OnInit {
|
|||
enableOAuth: [x.enableOAuth],
|
||||
enableHeaderAuth: [x.enableHeaderAuth],
|
||||
headerAuthVariable: [x.headerAuthVariable],
|
||||
headerAuthCreateUser: [x.headerAuthCreateUser],
|
||||
});
|
||||
this.form.controls.enableHeaderAuth.valueChanges.subscribe(x => {
|
||||
if (x) {
|
||||
|
|
|
@ -305,7 +305,20 @@ namespace Ombi.Controllers.V1
|
|||
var user = await _userManager.FindByNameAsync(username);
|
||||
if (user == null)
|
||||
{
|
||||
return new UnauthorizedResult();
|
||||
if (authSettings.HeaderAuthCreateUser)
|
||||
{
|
||||
user = new OmbiUser {
|
||||
UserName = username,
|
||||
UserType = UserType.LocalUser,
|
||||
StreamingCountry = "US",
|
||||
};
|
||||
|
||||
await _userManager.CreateAsync(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new UnauthorizedResult();
|
||||
}
|
||||
}
|
||||
|
||||
return await CreateToken(true, user);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue