mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 21:16:52 +01:00
Fix UserEnabled role being OR'd with action authorization roles FUUUUUCCCKK!!!!
Fixes #2064
This commit is contained in:
@@ -298,7 +298,10 @@ namespace Tgstation.Server.Host.Core
|
||||
services
|
||||
.AddScoped<GraphQL.Subscriptions.ITopicEventReceiver, ShutdownAwareTopicEventReceiver>()
|
||||
.AddGraphQLServer()
|
||||
.AddAuthorization()
|
||||
.AddAuthorization(
|
||||
options => options.AddPolicy(
|
||||
TgsAuthorizeAttribute.PolicyName,
|
||||
builder => builder.RequireRole(TgsAuthorizeAttribute.UserEnabledRole)))
|
||||
.ModifyOptions(options =>
|
||||
{
|
||||
options.EnsureAllNodesCanBeResolved = true;
|
||||
|
||||
@@ -15,10 +15,15 @@ namespace Tgstation.Server.Host.Security
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
sealed class TgsAuthorizeAttribute : AuthorizeAttribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Policy used to apply global requirement of <see cref="UserEnabledRole"/>.
|
||||
/// </summary>
|
||||
public const string PolicyName = "Policy.UserEnabled";
|
||||
|
||||
/// <summary>
|
||||
/// Role used to indicate access to the server is allowed.
|
||||
/// </summary>
|
||||
public const string UserEnabledRole = "Core.UserEnabled";
|
||||
public const string UserEnabledRole = "Role.UserEnabled";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="Api.Rights.RightsType"/> associated with the <see cref="TgsAuthorizeAttribute"/> if any.
|
||||
@@ -130,8 +135,12 @@ namespace Tgstation.Server.Host.Security
|
||||
private TgsAuthorizeAttribute(IEnumerable<string> roles)
|
||||
{
|
||||
var listRoles = roles.ToList();
|
||||
listRoles.Add(UserEnabledRole);
|
||||
Roles = String.Join(",", listRoles);
|
||||
if (listRoles.Count != 0)
|
||||
{
|
||||
Roles = String.Join(",", listRoles);
|
||||
}
|
||||
|
||||
Policy = PolicyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,8 +125,12 @@ namespace Tgstation.Server.Host.Security
|
||||
private TgsGraphQLAuthorizeAttribute(IEnumerable<string> roleNames)
|
||||
{
|
||||
var listRoles = roleNames.ToList();
|
||||
listRoles.Add(TgsAuthorizeAttribute.UserEnabledRole);
|
||||
Roles = [.. listRoles];
|
||||
if (listRoles.Count != 0)
|
||||
{
|
||||
Roles = [.. listRoles];
|
||||
}
|
||||
|
||||
Policy = TgsAuthorizeAttribute.PolicyName;
|
||||
Apply = ApplyPolicy.Validation;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user