Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda