mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-24 05:27:30 +01:00
Fix claiming
This commit is contained in:
@@ -33,12 +33,12 @@ namespace Tgstation.Server.Api
|
||||
/// <summary>
|
||||
/// The JWT authentication header scheme
|
||||
/// </summary>
|
||||
const string jwtAuthenticationScheme = "bearer";
|
||||
const string jwtAuthenticationScheme = "Bearer";
|
||||
|
||||
/// <summary>
|
||||
/// The password authentication header scheme
|
||||
/// </summary>
|
||||
const string passwordAuthenticationScheme = "password";
|
||||
const string passwordAuthenticationScheme = "Password";
|
||||
|
||||
/// <summary>
|
||||
/// The current <see cref="AssemblyName"/>
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Tgstation.Server.Api.Rights
|
||||
/// <param name="rightsType">The <see cref="RightsType"/></param>
|
||||
/// <param name="right">The right value</param>
|
||||
/// <returns>A <see cref="string"/> representing the claim role name</returns>
|
||||
public static string RoleName(RightsType rightsType, int right)
|
||||
public static string RoleName(RightsType rightsType, Enum right)
|
||||
{
|
||||
var enumType = typeMap[rightsType];
|
||||
return String.Concat(enumType.Name, '.', Enum.GetName(enumType, right));
|
||||
|
||||
@@ -88,10 +88,11 @@ namespace Tgstation.Server.Host.Controllers
|
||||
foreach (RightsType I in enumerator)
|
||||
{
|
||||
var rightInt = authenticationContext.GetRight(I);
|
||||
var right = (Enum)(ValueType)authenticationContext.GetRight(I);
|
||||
foreach(Enum J in Enum.GetValues(RightsHelper.RightToType(I)))
|
||||
var rightEnum = RightsHelper.RightToType(I);
|
||||
var right = (Enum)Enum.ToObject(rightEnum, authenticationContext.GetRight(I));
|
||||
foreach(Enum J in Enum.GetValues(rightEnum))
|
||||
if(right.HasFlag(J))
|
||||
claims.Add(new Claim(ClaimTypes.Role, RightsHelper.RoleName(I, rightInt)));
|
||||
claims.Add(new Claim(ClaimTypes.Role, RightsHelper.RoleName(I, J)));
|
||||
}
|
||||
|
||||
context.Principal.AddIdentity(new ClaimsIdentity(claims));
|
||||
|
||||
Reference in New Issue
Block a user