Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

matchingForGFunction in nodejs #298

Closed
fahussain opened this issue Jul 18, 2021 · 5 comments · Fixed by casbin/casbin-website#314
Closed

matchingForGFunction in nodejs #298

fahussain opened this issue Jul 18, 2021 · 5 comments · Fixed by casbin/casbin-website#314
Assignees
Labels
enhancement New feature or request

Comments

@fahussain
Copy link

First of all it's a wonderful library and thank you so much for sharing it with us.

I am trying to implement RBAC with domains and 'all' patterns matching using nodejs but I have not been able to figure out how to tell casbin to use which function for g matching. In the online editor I see that I need to specify:

 matchingForGFunction: 'keyMatch2',
 matchingDomainForGFunction: 'keyMatch2'

but I don't know how and where I need to pass this config. Any help would be greatly appreciated.

@sagilio
Copy link
Member

sagilio commented Jul 18, 2021

You can find it at: https://casbin.org/docs/en/rbac#use-pattern-matching-in-rbac

public async addMatchingFunc(name: string | MatchingFunc, fn?: MatchingFunc): Promise<void> {

@fahussain
Copy link
Author

fahussain commented Jul 18, 2021

@sagilio Thank you for your answer. I had two named grouping functions so I ended up using:

    <enforcer>.addNamedMatchingFunc('g', Util.keyMatch2Func);
    <enforcer>.addNamedMatchingFunc('g2', Util.keyMatch2Func);

I think it would be nice if an example of using this for nodejs was in the documentation too.

@hsluoyz hsluoyz transferred this issue from casbin/casbin Jul 19, 2021
@hsluoyz hsluoyz added the enhancement New feature or request label Jul 19, 2021
@hsluoyz
Copy link
Member

hsluoyz commented Jul 19, 2021

@Zxilly @Gabriel-403 plz add the Node.js code example to: https://casbin.org/docs/en/rbac#use-pattern-matching-in-rbac

@Shivansh-yadav13
Copy link
Member

is this issue still up?

@hsluoyz
Copy link
Member

hsluoyz commented Mar 3, 2022

@Shivansh-yadav13 yeah, plz add to docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants