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

Better support for the admin-reader role and various smaller fixes in role-based authorization #422

Merged
merged 9 commits into from Apr 28, 2022

Conversation

nhoening
Copy link
Contributor

No description provided.

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
… Also use API v3 to count a user's assets

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…'t need to do anymore after this PR

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@coveralls
Copy link
Collaborator

coveralls commented Apr 23, 2022

Pull Request Test Coverage Report for Build 2235467151

  • 12 of 15 (80.0%) changed or added relevant lines in 5 files are covered.
  • 46 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.02%) to 68.564%

Changes Missing Coverage Covered Lines Changed/Added Lines %
flexmeasures/ui/crud/users.py 8 9 88.89%
flexmeasures/api/play/routes.py 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
flexmeasures/data/schemas/sensors.py 1 79.59%
flexmeasures/cli/data_add.py 21 31.59%
flexmeasures/utils/config_utils.py 24 31.3%
Totals Coverage Status
Change from base Build 2207250748: -0.02%
Covered Lines: 7061
Relevant Lines: 9770

💛 - Coveralls

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening added this to the 0.10.0 milestone Apr 25, 2022
@nhoening nhoening requested a review from Flix6x April 25, 2022 11:39
…concepts in said API

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@Flix6x
Copy link
Contributor

Flix6x commented Apr 25, 2022

Can you guide me through this PR a bit? I find it hard to derive from reading the commit messages. For example, why did the removed test become redundant?

@nhoening
Copy link
Contributor Author

Sorry that there are a few things in here.

The big picture is to help admin-reader to actually read users (fixed in CRUD) and sensors (fixed in the sensor API).

On the way I noticed how

  • there is a bug in the roles_accepted decorator
  • we should always be using our decorators, not flask_security's
  • The CRUD endpoint GET /users/ was still using the v2 asset API

The test is removed because that endpoint stops doing an auth check. It now gives you only your account if you're not an admin, and all otherwise (which was the default behavior before).

Copy link
Contributor

@Flix6x Flix6x 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 clarifying. That helped a lot. I only have an issue with removing that test.

And to me it looks like we should also backport this PR to 0.9.x.

flexmeasures/ui/crud/users.py Outdated Show resolved Hide resolved
flexmeasures/ui/tests/test_user_crud.py Show resolved Hide resolved
flexmeasures/api/play/routes.py Outdated Show resolved Hide resolved
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening
Copy link
Contributor Author

We should release v0.10 soonish, and the bugs in this don't seem overly impactful, so for me back-porting is not required.

@nhoening nhoening requested a review from Flix6x April 27, 2022 20:19
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

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

Okay.

@nhoening nhoening merged commit c739c46 into main Apr 28, 2022
@nhoening nhoening deleted the user-crud-auth-admin-reader branch April 28, 2022 14:15
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.

None yet

3 participants