Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add RBAC decorator and plugin #321

Merged
merged 8 commits into from
Mar 28, 2021

Conversation

davidolrik
Copy link
Contributor

Role based authentication for use in plugins.

Included in this pull request is two decorators: rbac_require_any_role and rbac_require_all_role, and a "admin" plugin for assigning roles dynamically, and for being notified of people trying to use commands they aren't allowed to.

# User must have any one of the listed roles
@respond_to(regex=r'^my cool command$')
@rbac_require_any_role(['root', 'admin'])
def my_cool_comand(self, msg):
    pass

# User must have all of the listed roles
@respond_to(regex=r'^my other command$')
@rbac_require_all_roles(['role1', 'role2'])
def my_other_comand(self, msg):
    pass

Still needs docs and better error handling for edge cases.

@DonDebonair
Copy link
Owner

This is super useful! Needs docs indeed.

In my opinion, we could get rid of the rbac prefixes in the decorator. It's clear from the rest of the decorator names what it's doing.

@DonDebonair
Copy link
Owner

@davidolrik I'd still love to include this, but it still needs documentation. Are you planning to provide that?

@davidolrik
Copy link
Contributor Author

Definitely!

@davidolrik davidolrik changed the title WIP: Add RBAC decorator and plugin Add RBAC decorator and plugin Jul 26, 2020
@davidolrik
Copy link
Contributor Author

@dandydev: I've added docs - let me know if it is enough, and if it is placed correctly.

@davidolrik
Copy link
Contributor Author

I've also rebased it with master so it should be easy to merge.

@davidolrik davidolrik force-pushed the rbac-decorators branch 2 times, most recently from 588c61f to f1a9a5a Compare August 6, 2020 11:10
@davidolrik
Copy link
Contributor Author

Rebased with master.

@davidolrik
Copy link
Contributor Author

Rebased with master.

@davidolrik
Copy link
Contributor Author

@dandydev Are there anything more needed for this to be merged?

@DonDebonair
Copy link
Owner

Sorry for the super late response. I was switching jobs and have a new puppy that takes a lot of my spare time. This looks great and there's only one small change in the docs that is required before I can merge.

@davidolrik
Copy link
Contributor Author

No worries =) - I have a Golden my self, which kind of puppy?

@DonDebonair
Copy link
Owner

image

A golden as well! <3

@davidolrik
Copy link
Contributor Author

A9B80BFF-74FD-4B40-8386-83C1A86C06B7_1_105_c

@DonDebonair
Copy link
Owner

What a lovely doggo!

This PR has turned out to be the most wholesome PR in my open source career so far ;)

@DonDebonair DonDebonair merged commit 6ad4a56 into DonDebonair:master Mar 28, 2021
@DonDebonair
Copy link
Owner

Merged!

@davidolrik
Copy link
Contributor Author

Lets make more PR's like this then 😁

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants