mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-01 04:34:26 -04:00
Fix more issues
This commit is contained in:
parent
d27b2481a0
commit
d35a7ba8bd
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Authentication;
|
using System.Security.Authentication;
|
||||||
using Emby.Server.Implementations.SocketSharp;
|
using Emby.Server.Implementations.SocketSharp;
|
||||||
|
using Jellyfin.Data.Entities;
|
||||||
using Jellyfin.Data.Enums;
|
using Jellyfin.Data.Enums;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
@ -44,14 +45,14 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
ValidateUser(request, authAttribtues);
|
ValidateUser(request, authAttribtues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Jellyfin.Data.Entities.User Authenticate(HttpRequest request, IAuthenticationAttributes authAttributes)
|
public User Authenticate(HttpRequest request, IAuthenticationAttributes authAttributes)
|
||||||
{
|
{
|
||||||
var req = new WebSocketSharpRequest(request, null, request.Path, _logger);
|
var req = new WebSocketSharpRequest(request, null, request.Path, _logger);
|
||||||
var user = ValidateUser(req, authAttributes);
|
var user = ValidateUser(req, authAttributes);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Jellyfin.Data.Entities.User ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues)
|
private User ValidateUser(IRequest request, IAuthenticationAttributes authAttribtues)
|
||||||
{
|
{
|
||||||
// This code is executed before the service
|
// This code is executed before the service
|
||||||
var auth = _authorizationContext.GetAuthorizationInfo(request);
|
var auth = _authorizationContext.GetAuthorizationInfo(request);
|
||||||
@ -104,9 +105,9 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ValidateUserAccess(
|
private void ValidateUserAccess(
|
||||||
Jellyfin.Data.Entities.User user,
|
User user,
|
||||||
IRequest request,
|
IRequest request,
|
||||||
IAuthenticationAttributes authAttribtues,
|
IAuthenticationAttributes authAttributes,
|
||||||
AuthorizationInfo auth)
|
AuthorizationInfo auth)
|
||||||
{
|
{
|
||||||
if (user.HasPermission(PermissionKind.IsDisabled))
|
if (user.HasPermission(PermissionKind.IsDisabled))
|
||||||
@ -120,7 +121,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!user.HasPermission(PermissionKind.IsAdministrator)
|
if (!user.HasPermission(PermissionKind.IsAdministrator)
|
||||||
&& !authAttribtues.EscapeParentalControl
|
&& !authAttributes.EscapeParentalControl
|
||||||
&& !user.IsParentalScheduleAllowed())
|
&& !user.IsParentalScheduleAllowed())
|
||||||
{
|
{
|
||||||
request.Response.Headers.Add("X-Application-Error-Code", "ParentalControl");
|
request.Response.Headers.Add("X-Application-Error-Code", "ParentalControl");
|
||||||
@ -178,7 +179,7 @@ namespace Emby.Server.Implementations.HttpServer.Security
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ValidateRoles(string[] roles, Jellyfin.Data.Entities.User user)
|
private static void ValidateRoles(string[] roles, User user)
|
||||||
{
|
{
|
||||||
if (roles.Contains("admin", StringComparer.OrdinalIgnoreCase))
|
if (roles.Contains("admin", StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -89,14 +89,13 @@ namespace Jellyfin.Data.Entities
|
|||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
[ForeignKey("Permission_GroupPermissions_Id")]
|
[ForeignKey("Permission_GroupPermissions_Id")]
|
||||||
public ICollection<Permission> Permissions { get; protected set; }
|
public virtual ICollection<Permission> Permissions { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("ProviderMapping_ProviderMappings_Id")]
|
[ForeignKey("ProviderMapping_ProviderMappings_Id")]
|
||||||
public ICollection<ProviderMapping> ProviderMappings { get; protected set; }
|
public virtual ICollection<ProviderMapping> ProviderMappings { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("Preference_Preferences_Id")]
|
[ForeignKey("Preference_Preferences_Id")]
|
||||||
public ICollection<Preference> Preferences { get; protected set; }
|
public virtual ICollection<Preference> Preferences { get; protected set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ namespace Jellyfin.Data.Entities
|
|||||||
[Required]
|
[Required]
|
||||||
public long InternalId { get; set; }
|
public long InternalId { get; set; }
|
||||||
|
|
||||||
public ImageInfo ProfileImage { get; set; }
|
public virtual ImageInfo ProfileImage { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the row version.
|
/// Gets or sets the row version.
|
||||||
@ -241,24 +241,26 @@ namespace Jellyfin.Data.Entities
|
|||||||
* Navigation properties
|
* Navigation properties
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
[ForeignKey("Group_Groups_Guid")]
|
[ForeignKey("Group_Groups_Guid")]
|
||||||
public ICollection<Group> Groups { get; protected set; }
|
public virtual ICollection<Group> Groups { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("Permission_Permissions_Guid")]
|
[ForeignKey("Permission_Permissions_Guid")]
|
||||||
public ICollection<Permission> Permissions { get; protected set; }
|
public virtual ICollection<Permission> Permissions { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("ProviderMapping_ProviderMappings_Id")]
|
[ForeignKey("ProviderMapping_ProviderMappings_Id")]
|
||||||
public ICollection<ProviderMapping> ProviderMappings { get; protected set; }
|
public virtual ICollection<ProviderMapping> ProviderMappings { get; protected set; }
|
||||||
|
|
||||||
[ForeignKey("Preference_Preferences_Guid")]
|
[ForeignKey("Preference_Preferences_Guid")]
|
||||||
public ICollection<Preference> Preferences { get; protected set; }
|
public virtual ICollection<Preference> Preferences { get; protected set; }
|
||||||
|
|
||||||
public ICollection<AccessSchedule> AccessSchedules { get; protected set; }
|
public virtual ICollection<AccessSchedule> AccessSchedules { get; protected set; }
|
||||||
|
|
||||||
partial void Init();
|
partial void Init();
|
||||||
|
|
||||||
public bool HasPermission(PermissionKind permission)
|
public bool HasPermission(PermissionKind permission)
|
||||||
{
|
{
|
||||||
return Permissions.First(p => p.Kind == permission).Value;
|
var list = Permissions.Where(p => p.Kind == permission);
|
||||||
|
|
||||||
|
return list.First().Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPermission(PermissionKind kind, bool value)
|
public void SetPermission(PermissionKind kind, bool value)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.3" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.3" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -65,8 +65,10 @@ namespace Jellyfin.Server
|
|||||||
|
|
||||||
// TODO: Set up scoping and use AddDbContextPool
|
// TODO: Set up scoping and use AddDbContextPool
|
||||||
serviceCollection.AddDbContext<JellyfinDb>(
|
serviceCollection.AddDbContext<JellyfinDb>(
|
||||||
options => options.UseSqlite($"Filename={Path.Combine(ApplicationPaths.DataPath, "jellyfin.db")}"),
|
options => options
|
||||||
ServiceLifetime.Transient);
|
.UseSqlite($"Filename={Path.Combine(ApplicationPaths.DataPath, "jellyfin.db")}")
|
||||||
|
.UseLazyLoadingProxies(),
|
||||||
|
ServiceLifetime.Transient);
|
||||||
|
|
||||||
serviceCollection.AddSingleton<JellyfinDbProvider>();
|
serviceCollection.AddSingleton<JellyfinDbProvider>();
|
||||||
|
|
||||||
|
@ -276,7 +276,8 @@ namespace MediaBrowser.Api
|
|||||||
{
|
{
|
||||||
var result = _userManager
|
var result = _userManager
|
||||||
.Users
|
.Users
|
||||||
.Where(item => !item.HasPermission(PermissionKind.IsDisabled));
|
.Where(user => !user.HasPermission(PermissionKind.IsDisabled))
|
||||||
|
.AsQueryable();
|
||||||
|
|
||||||
if (ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
|
if (ServerConfigurationManager.Configuration.IsStartupWizardCompleted)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user