Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

261
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda