-
Notifications
You must be signed in to change notification settings - Fork 53
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
[ENH] Allow fetching of arbitrary user environments #864
[ENH] Allow fetching of arbitrary user environments #864
Conversation
✅ Deploy Preview for conda-store canceled.
|
62c040a
to
71c2cb7
Compare
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.
Thanks @peytondmurray I left a number of suggestions and questions.
Other questions as this was not entirely clear to me from the PR description and after seeing the tests.
- As an end user if I want to use the REST API to get a list of envs I need to pass then
role_mapping={
"*/*": ["editor"],
"default/env": ["viewer"]
}
as a query parameter like environments?role_mapping
? or how would you expect this to work?
- if so, what happens if the user does not provide a role for example
role_mapping={
"*/*",
}
is that even possible?
No, that's only for the Python API. For the REST API, you pass a JWT of the user you want to fetch environments for, e.g.
Role mappings are dictionaries, so this isn't currently possible - you need associated roles in order for this to work. |
407361d
to
a71899b
Compare
So for the REST API the default behavior is to just return all the environments a user has some access to. |
No, sorry, I should have made that more clear - for the REST API, any user This is the line that grabs the environments for and this is the line that filters those environments by those that are visible to the requester |
Right I did see the filtering when doing the code review this
was what confused me. So all good then. |
100% agreed. Once the openapi.json reference is updated we'll have that. But maybe it make sense to start a document where some common uses cases are shown in examples? |
Co-authored-by: Chuck McAndrew <[email protected]>
a71899b
to
494aaf3
Compare
Fixes #857.
Description
This pull request:
/environment/
endpoint. The response will include only environments visible to the specified JWT.role_mapping
parameter for the corresponding Python API,conda_store_server.api.list_environments
. The role mapping should be a dictionary of the same type used to configure role mappings in theconda_store_config.py
, e.g. passing:to
list_environments
would return only environments that match either of the two dictionary keys; the keys mean the same thing as they do in theconda_store_config.py
:"*/*"
= match all namespace names and match all environment names"default/env"
= match any namespace named "default" and match any environment named "env"conda_store_server.server.auth.AuthenticationBackend.compile_arn_sql_like
, which turns a role mapping key into a SQL-compatible regex that can be used to filter namespaces and backends, toconda_store_server._internal.utils.compile_arn_sql_like
so that I could use it outside of theAuthenticationBackend
. Doing this required updating a few different files, and I took the opportunity to define some useful type aliases, leave some type annotations, and add some docstrings.Pull request checklist
How to test
Tests of new functionality in both the REST API and the Python API were added, so CI should take care of this. You can also run them locally with
pytest
.