Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Support Manager role #1223

Closed
wants to merge 1 commit into from
Closed

Conversation

mvalois
Copy link
Contributor

@mvalois mvalois commented Nov 12, 2020

Wanna fix #1136
This is my first time with Rust. Feel free to ask for changes (especially for error handling).
Maybe the function check_manager_in_collection can be moved to a better spot.

@BlackDex
Copy link
Collaborator

This is just a copy of the recently closed PR #1222 which noted that there probably should be a better way to do this.
And i think there is. These checks should not be done per function. That is where the ManagerHeader should be for.
So that check should end-up somewhere in auth.rs in my opinion. And emit a error there if the user doesn't have the right permissions. Though this can be tricky if we do not have all the information.

@mvalois
Copy link
Contributor Author

mvalois commented Nov 12, 2020

You mean it is possible not to add any extra line in collections.rs except changing headers to ManagerHeaders ?

@BlackDex
Copy link
Collaborator

Yes, there is. You probably need to do these checks in auth.rs, and when thinking about it and checking your changes, there are also some cases where you have access as a Manager, but there is no collection_id provided. But those items you want to have checked before they enter the function at all i think.

Also, i see some other issues like always saving the CollectionUser, which should not be done when the user as access to all collections. And i'm missing some function, like changing a collection name.

BlackDex added a commit to BlackDex/vaultwarden that referenced this pull request Nov 27, 2020
This has been requested a few times (dani-garcia#1136 & dani-garcia#246 & forum), and there already were two
(1:1 duplicate) PR's (dani-garcia#1222 & dani-garcia#1223) which needed some changes and no
followups or further comments unfortunally.

This PR adds two auth headers.
- ManagerHeaders
  Checks if the user-type is Manager or higher and if the manager is
part of that collection or not.
- ManagerHeadersLoose
  Check if the user-type is Manager or higher, but does not check if the
user is part of the collection, needed for a few features like
retreiving all the users of an org.

I think this is the safest way to implement this instead of having to
check this within every function which needs this manually.

Also some extra checks if a manager has access to all collections or
just a selection.
BlackDex added a commit to BlackDex/vaultwarden that referenced this pull request Dec 2, 2020
This has been requested a few times (dani-garcia#1136 & dani-garcia#246 & forum), and there already were two
(1:1 duplicate) PR's (dani-garcia#1222 & dani-garcia#1223) which needed some changes and no
followups or further comments unfortunally.

This PR adds two auth headers.
- ManagerHeaders
  Checks if the user-type is Manager or higher and if the manager is
part of that collection or not.
- ManagerHeadersLoose
  Check if the user-type is Manager or higher, but does not check if the
user is part of the collection, needed for a few features like
retreiving all the users of an org.

I think this is the safest way to implement this instead of having to
check this within every function which needs this manually.

Also some extra checks if a manager has access to all collections or
just a selection.

fixes dani-garcia#1136
@BlackDex
Copy link
Collaborator

BlackDex commented Dec 8, 2020

Going to close this PR as #1242 has been merged :).
Thanks for the PR, and making it clear this was a needed feature.

@BlackDex BlackDex closed this Dec 8, 2020
@mvalois
Copy link
Contributor Author

mvalois commented Dec 9, 2020

Thank you for your time!

Koisell pushed a commit to Koisell/vaultwarden that referenced this pull request Feb 17, 2021
This has been requested a few times (dani-garcia#1136 & dani-garcia#246 & forum), and there already were two
(1:1 duplicate) PR's (dani-garcia#1222 & dani-garcia#1223) which needed some changes and no
followups or further comments unfortunally.

This PR adds two auth headers.
- ManagerHeaders
  Checks if the user-type is Manager or higher and if the manager is
part of that collection or not.
- ManagerHeadersLoose
  Check if the user-type is Manager or higher, but does not check if the
user is part of the collection, needed for a few features like
retreiving all the users of an org.

I think this is the safest way to implement this instead of having to
check this within every function which needs this manually.

Also some extra checks if a manager has access to all collections or
just a selection.

fixes dani-garcia#1136
thelittlefireman pushed a commit to thelittlefireman/bitwarden_rs that referenced this pull request Mar 19, 2021
This has been requested a few times (dani-garcia#1136 & dani-garcia#246 & forum), and there already were two
(1:1 duplicate) PR's (dani-garcia#1222 & dani-garcia#1223) which needed some changes and no
followups or further comments unfortunally.

This PR adds two auth headers.
- ManagerHeaders
  Checks if the user-type is Manager or higher and if the manager is
part of that collection or not.
- ManagerHeadersLoose
  Check if the user-type is Manager or higher, but does not check if the
user is part of the collection, needed for a few features like
retreiving all the users of an org.

I think this is the safest way to implement this instead of having to
check this within every function which needs this manually.

Also some extra checks if a manager has access to all collections or
just a selection.

fixes dani-garcia#1136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Org managers can't create or manage collections
2 participants