When using the source generator for ACL the public static Dictionary<string, string> Descriptions ... also gets included in _permNames and __permCodes resulting in incorrect values being returned by the utility functions like AllCodes().
Steps to reproduce
Scaffold a new FE project using one of the official templates
Install the FastEndpoints.Generator package
Go into SayHello.Endpoint and register a permission in the following way:
public override void Configure()
{
Post("/api/hello");
AllowAnonymous();
AccessControl("TestPermission");
}
Now either use the debugger to call a utility function on the Allow class, or use the logger like so:
public override async Task HandleAsync(Request r, CancellationToken c)
{
Logger.LogInformation(JsonSerializer.Serialize(Allow.AllCodes()));
...
The logged codes should look similar: ["System.Collections.Generic.Dictionary\u00602[System.String,System.String]","PDW"]
Everything described here was using the latest version on FE (5.25.0) and .net 8.0.
Temporary workaround for those facing this
Extend the partial allow class like so:
public partial class Allow
{
static partial void Describe()
{
// Fixed the source generator incorrectly registering the Descriptions prop as a permission
_permCodes.Remove("System.Collections.Generic.Dictionary`2[System.String,System.String]");
_permNames.Remove("Descriptions");
}
}
Description
When using the source generator for ACL the
public static Dictionary<string, string> Descriptions ...
also gets included in_permNames
and__permCodes
resulting in incorrect values being returned by the utility functions likeAllCodes()
.Steps to reproduce
Go into
SayHello.Endpoint
and register a permission in the following way:Allow
class, or use the logger like so:["System.Collections.Generic.Dictionary\u00602[System.String,System.String]","PDW"]
Everything described here was using the latest version on FE (5.25.0) and .net 8.0.
Temporary workaround for those facing this
Extend the partial allow class like so: