Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

255
Views
Can you define Casl Rules based on User attributes?

When defining rules in CASL you can state a User's abilities for which Subject (Model) based on the subject's attributes.

In the below example from the docs you're defining that the user can read an Article if it's 'attribute' published is false.

enter image description here

I would like to know if I can also add User attributes in the conditions, whereby for example you can only read an Article if published === false && user.is_active === true.

The example from the docs below shows this being done with an if statement before defining the rules (obviously not a feature of CASL, just standard javascript conditional).

enter image description here

Can this be done on the rule somehow, in the can function call, as let's say a passed parameter?

CASL states...

CASL implements Attribute Based Access Control

And I think ABAC is based on attributes other than just the Object being accessed. Like attributes for the User or Environment. See here and here.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!