You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's your scenario? What do you want to achieve?
I have a set of objects, and I want to check if the user has access to these objects based on a given action type. I am using Casbin .NET and the BatchEnforce service, but I always get false. However, when I loop through the set and use Enforce one by one, I get the correct results
Here is the object I created that implements IRequestValues :
public class ObjectRequest : IRequestValues
{
public string Sub{ get; set; }
public Attributes Obj { get; set; }
public string Action { get; set; }
public bool TrySetValue<T>(int index, T value)
{
try
{
switch (index)
{
case 0:
Sub= value as string ?? throw new InvalidCastException("Submust be a string");
break;
case 1:
Obj=
value as Attributes
?? throw new InvalidCastException("Object must be of type Attributes");
break;
case 2:
Action = value as string ?? throw new InvalidCastException("Action must be a string");
break;
default:
return false;
}
return true;
}
catch
{
return false;
}
}
public string this[int index]
{
get
{
return index switch
{
0 => Sub,
1 => Obj.ToString(),
3 => Action,
_ => throw new IndexOutOfRangeException($"Invalid index: {index}")
};
}
}
public int Count => 3;
}
And here is the Attributes object definition :
public class Attributes : IRequestValues
{
public string type{ get; set; }
public string color{ get; set; }
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
The text was updated successfully, but these errors were encountered:
Want to prioritize this issue? Try:
What's your scenario? What do you want to achieve?
I have a set of objects, and I want to check if the user has access to these objects based on a given action type. I am using Casbin .NET and the BatchEnforce service, but I always get false. However, when I loop through the set and use Enforce one by one, I get the correct results
Your model:
Your policy:
Your request(s):
Here is the object I created that implements IRequestValues :
And here is the Attributes object definition :
The text was updated successfully, but these errors were encountered: