feathers-casl icon indicating copy to clipboard operation
feathers-casl copied to clipboard

Enable verbose logging/debug with `relevantRuleFor`

Open robbyphillips opened this issue 3 years ago • 1 comments

It would really nice to optionally enable verbose logging using CASL's relevantRuleFor feature. https://casl.js.org/v5/en/advanced/debugging-testing#debugging

I can think of three different ways that we might expose it

  1. Attach data to the Forbidden error when something like authorize({ relevantRule: true })
  2. Use something like the debug library and just print the info when an environment variable is set. I think feathers core does this.
  3. Give the necessary context to the actionOnForbidden callback and leave the logging to the library consumer.

What do you think? If any of these sound good, I would be willing to make a PR.

robbyphillips avatar Jun 03 '21 21:06 robbyphillips

Hey @robbyphillips, sorry for the delay! Thanks for your issue and thoughts. I definitely would go for the debug library. I should use it for my libraries, I admit. A PR would be highly appreciated and merged soon. If you got time, please feel free to start with the branch: https://github.com/fratzinger/feathers-casl/tree/basic-permission-performant-select as I will merge it to master soon.

Many thanks in advance! 👍

fratzinger avatar Aug 02 '21 18:08 fratzinger