-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add support for the editor
role
#738
Conversation
✅ Deploy Preview for kaleidoscopic-dango-0cf31d canceled.
|
5f22c1c
to
f74e867
Compare
Lets go through a few examples to make this more concrete and assume | ||
Additionally, the role `editor` can be used, which is an alias for `developer`. | ||
|
||
Let's go through a few examples to make this more concrete and assume |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo fix: "Lets" -> "Let's"
One of the previous commits explicitly defined both aliases in `role_mappings`, but that was wrong because only one value is used in the DB, which is `developer`. Instead, you need to map `developer` from the DB to `role_mappings`, which can either have `editor` (new name) or `developer` (legacy name). The new name is checked first, then the old one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the one area that I think needs changed. Other than that, looks good.
# Additionally, this code allows for legacy 'role_mappings' that | ||
# used to specify the role as 'developer'. Because it's a | ||
# user-visible setting, we cannot break compatibility here | ||
assert role != "editor" # must NEVER be 'editor' in the DB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An assert outside of a test strikes me as odd. Looking into it, it seems like some compilation flags remove assert statements. If this check is valuable, I think raising an exception here would be more valuable. However, I am not sure that this represents an unrecoverable error, since we would still know what to do with that data. We could just handle it and log an warning that data that shouldn't be in the db is. Or if it really does represent an unrecoverable error, than raising an exception seems better than an assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcmcand Changed to raise
. It's not unrecoverable, but it's a mistake that's easy to make when potentially refactoring or adding new DB APIs.
For example, see the change in conda-store-server/conda_store_server/api.py
in this PR. The old code would bypass validate_role
because .update
is a lowel-level API, which just skips ORM validation logic. That was caught by the tests, which is how I noticed. But we might not have good coverage for some new yet to be added APIs, so I want to make sure this is never a problem.
@dcmcand PTAL. Note: I want to keep the diff minimal to make it easier to review, I'll rebase after this is approved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Fixes #675.
Description
This pull request:
editor
fordeveloper
to role mappings, which is supported by the HTTP API and the DBThe auth flow is as follows:
editor
ordeveloper
)developer
)role_mappings
developer
from the DB is matched againsteditor
ordeveloper
inrole_mappings
(in this order).All user-visible parameters (the HTTP API and the
role_mappings
setting) allow for botheditor
anddeveloper
.The name
editor
is preferred, which is reflected in the documentation.The name
developer
is supported for compatibility reasons.How I tested this locally:
role_mappings
are actually used by the test, I commented outeditor
in the defaultrole_mappings
developer
is still supported, I replacededitor
withdeveloper
in the defaultrole_mappings
editor
in the defaultrole_mappings
After making each of these changes in the application, I ran
PYTEST_ADDOPTS="-rpfxs -k test_end_to_end_auth_flow" pytest tests
and looked at the test output.
Pull request checklist
Additional information