Remove api key check and simplify conditions
This commit is contained in:
parent
7221e7ca68
commit
ed1b880359
|
@ -31,20 +31,20 @@ namespace Jellyfin.Api.Auth.FirstTimeSetupPolicy
|
||||||
context.Succeed(requirement);
|
context.Succeed(requirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Succeed if user is admin or api key
|
// Succeed if user is admin
|
||||||
else if (context.User.GetIsApiKey() || context.User.IsInRole(UserRoles.Administrator))
|
else if (context.User.IsInRole(UserRoles.Administrator))
|
||||||
{
|
{
|
||||||
context.Succeed(requirement);
|
context.Succeed(requirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if admin is required and user is not admin
|
// Fail if admin is required and user is not admin
|
||||||
else if (requirement.RequireAdmin && !context.User.IsInRole(UserRoles.Administrator))
|
else if (requirement.RequireAdmin)
|
||||||
{
|
{
|
||||||
context.Fail();
|
context.Fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Succeed if admin is not required and user is not guest
|
// Succeed if admin is not required and user is not guest
|
||||||
else if (!requirement.RequireAdmin && context.User.IsInRole(UserRoles.User))
|
else if (context.User.IsInRole(UserRoles.User))
|
||||||
{
|
{
|
||||||
context.Succeed(requirement);
|
context.Succeed(requirement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,16 +106,6 @@ namespace Jellyfin.Api.Tests.Auth.FirstTimeSetupPolicy
|
||||||
Assert.Equal(shouldSucceed, allowed.Succeeded);
|
Assert.Equal(shouldSucceed, allowed.Succeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
|
||||||
public async Task ShouldAllowAdminApiKeyIfStartupWizardComplete()
|
|
||||||
{
|
|
||||||
TestHelpers.SetupConfigurationManager(_configurationManagerMock, true);
|
|
||||||
var claims = new ClaimsPrincipal(new ClaimsIdentity([new Claim(InternalClaimTypes.IsApiKey, bool.TrueString)]));
|
|
||||||
|
|
||||||
var allowed = await _authorizationService.AuthorizeAsync(claims, "FirstTime");
|
|
||||||
Assert.True(allowed.Succeeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task ShouldDisallowUserIfOutsideSchedule()
|
public async Task ShouldDisallowUserIfOutsideSchedule()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user