Skip to content

Conversation

@pwizla
Copy link
Collaborator

@pwizla pwizla commented Mar 9, 2021

What does it do?

Describes how to define & add custom conditions for RBAC management.

Why is it needed?

There was no doc entry on how to add custom RBAC conditions yet 😅

Related issue(s)/PR(s)

The goal is to deploy it along with #118 (Add RBAC in user-guide)

@pwizla pwizla added the source: Dev Docs PRs/issues targeting the Developer Docs label Mar 9, 2021
@pwizla pwizla changed the title Developer/rbac Add RBAC (custom conditions) to Developer docs Mar 9, 2021
Copy link
Collaborator

@meganelacheny meganelacheny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this documentation!

I suggested some improvements. Also, on a more general note, I'm not sure we should use "you" that much in a documentation. It's fine when used here and there, but especially when explaining procedures/actions to follow, I personally prefer when it's a bit more impersonal.

@derrickmehaffy
Copy link
Member

@pwizla / @meganelacheny just an FYI most of this documentation was written by @alexandrebodin originally so if there is anything that is not clear it would be best to loop him in to review as well.

@pwizla pwizla requested a review from alexandrebodin March 11, 2021 09:39
Copy link

@lauriejim lauriejim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this documentation.
I added some comments.

Copy link
Member

@derrickmehaffy derrickmehaffy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derrickmehaffy derrickmehaffy requested review from Convly and petersg83 and removed request for alexandrebodin March 12, 2021 15:49
@derrickmehaffy
Copy link
Member

@Convly / @petersg83 if either of you get some time can you just review this and make sure everything looks good to you from a backend perspective

@pwizla pwizla requested review from Convly and petersg83 March 15, 2021 16:36
@pwizla
Copy link
Collaborator Author

pwizla commented Mar 15, 2021

Thank you very much for all your reviews and comments!

@petersg83 and @Convly , just wanted to mention that this PR is ready for another (final?) review. I hope this doc is now even clearer, more inclusive and more comprehensive :-)

Copy link
Contributor

@petersg83 petersg83 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it looks good to me :)

Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there 🎉


#### Using the condition handler

The condition `handler` is used to verify the condition on the entities you read, create, update or delete. It can be a query object or a function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, a condition can be applied to every permission.
The condition query object, however, will only work for permission attached to a particular subject (aka entity).

For instance, I could create a condition that allows me to access a particular page of the admin panel only if the server date is 5pm. In this scenario, my action is not related to any subject/entity and my condition would look like this: handler: () => new Date().getHours() === 17

Copy link
Collaborator Author

@pwizla pwizla Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I seeeeee! Thank you very much for clarifying, JS! Really interesting example :-)

So I updated the content with this commit.

@Convly Convly self-requested a review March 23, 2021 10:44
Copy link
Member

@Convly Convly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice job!

@pwizla
Copy link
Collaborator Author

pwizla commented Mar 23, 2021

LGTM, nice job!

Thanks so much for your help! 🙌 😊

@pwizla pwizla merged commit 0fdad30 into main Mar 24, 2021
@pwizla pwizla deleted the developer/rbac branch March 24, 2021 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

source: Dev Docs PRs/issues targeting the Developer Docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants