FastEndpoints / FastEndpoints

A light-weight REST API development framework for ASP.NET 6 and newer.
https://fast-endpoints.com
MIT License
4.74k stars 283 forks source link

Bug: Generated ACL incorrectly contains the descriptions dictionary in the permission dictionarys #683

Closed Xeretis closed 6 months ago

Xeretis commented 6 months ago

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 like AllCodes().

Steps to reproduce

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");
    }
}
Xeretis commented 6 months ago

I'll look into creating a pr to properly fix this in a minute.