casbin / Casbin.NET

An authorization library that supports access control models like ACL, RBAC, ABAC in .NET (C#)
https://casbin.org
Apache License 2.0
1.14k stars 110 forks source link

feat: Add globMatch to BuildInFunctions #231

Closed dviry closed 2 years ago

dviry commented 2 years ago

Using Casbin.NET v1.11.0 - getting the following error when trying to use globMatch() as a matcher:

DynamicExpresso.Exceptions.UnknownIdentifierException: 'Unknown identifier 'globMatch' 

In the past I've used DotNet.Glob - can we integrate it as a built-in function?

Thanks in advance

casbin-bot commented 2 years ago

@sagilio @xcaptain @huazhikui

dviry commented 2 years ago

PS: currently I'm adding it dynamically to the Enforcer instance:

enforcer.AddFunction("globMatch", (string key1, string key2) => Glob.Parse(key2).IsMatch(key1));
hsluoyz commented 2 years ago

@sagilio any comment?

@dviry can you make a PR?