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
Thanks for the contribution! A couple of things though: node-casbin doesn't host usage guides — all docs live in the casbin-website repo (casbin.apache.org/docs), so a docs/ file here wouldn't be linked or discoverable. We also already have an official NestJS integration, nest-authz (https://github.com/apache/casbin-nest-authz) with a full example repo, so a guide should build on that rather than a hand-rolled guard. The example itself also has a few issues worth fixing first: the subject is hardcoded to 'alice' instead of read from request.user, request.url includes the query string so /data?page=1 won't match the /data policy (RESTful paths need keyMatch2), the enforcer is created in an async onModuleInit without implements OnModuleInit (racy — better to provide the Enforcer as a useFactory provider and inject it), and every code block is tagged ```bash even for TS/conf/csv. I'd suggest closing this and opening a PR against casbin-website instead. Thanks again!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a NestJS integration example for Casbin using a custom guard.
It demonstrates how to use Casbin for authorization in a NestJS application, including installation, guard implementation, and policy configuration.
The example shows how to protect routes using a NestJS guard and enforce access control with Casbin.
This will help developers easily integrate Casbin with modern Node.js frameworks like NestJS.