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

get groups from authenticator; improve group mgmt on admin page #3307

Closed
wants to merge 9 commits into from

Conversation

eliaswimmer
Copy link

@eliaswimmer eliaswimmer commented Dec 16, 2020

  • Authenticator can supply a group field with group memberships for user
    Groups will be created if no already existing

  • Manage groups via admin page

    • Add and delete groups
    • assign and revoke groups to/from users
  • Self clearing fixtures for user(s) and group(s)

* Authenticator can supply a group field with group memberships for user
  Groups will be created if no already existing

* Manage groups via admin page
  * Add and delete groups
  * assign and revoke groups to/from users
@welcome
Copy link

welcome bot commented Dec 16, 2020

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Copy link
Author

@eliaswimmer eliaswimmer left a comment

Choose a reason for hiding this comment

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

Tests still missing

self.db.commit()
deleted.append(group)
self.write(json.dumps([self.group_model(group) for group in deleted]))
self.set_status(201)
Copy link
Author

Choose a reason for hiding this comment

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

What is the correct return code for bulk delete

Copy link
Member

Choose a reason for hiding this comment

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

204, generally

Copy link
Author

Choose a reason for hiding this comment

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

has to be 200, as 204 does not allow to have a body

@@ -195,7 +203,7 @@ async def get(self, name):
@admin_only
async def post(self, name):
data = self.get_json_body()
user = self.find_user(name)
Copy link
Author

Choose a reason for hiding this comment

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

No need for the full User Object?!

@@ -244,7 +259,7 @@ async def delete(self, name):

@admin_only
async def patch(self, name):
user = self.find_user(name)
Copy link
Author

Choose a reason for hiding this comment

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

Do we really need the full User object here?

Copy link
Member

Choose a reason for hiding this comment

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

Is there a downside to consistency? In nearly all cases, the user is in memory already, and this adds only a single dict lookup to return the object.

Copy link
Member

@minrk minrk left a comment

Choose a reason for hiding this comment

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

This is great! I left a little feedback int he Python code, but everything looks nice. I will take the UI updates for a spin a bit later.

self.db.commit()
deleted.append(group)
self.write(json.dumps([self.group_model(group) for group in deleted]))
self.set_status(201)
Copy link
Member

Choose a reason for hiding this comment

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

204, generally

@@ -244,7 +259,7 @@ async def delete(self, name):

@admin_only
async def patch(self, name):
user = self.find_user(name)
Copy link
Member

Choose a reason for hiding this comment

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

Is there a downside to consistency? In nearly all cases, the user is in memory already, and this adds only a single dict lookup to return the object.

else:
setattr(user, key, value)
self.db.commit()
user_ = self.user_model(user)
user_['auth_state'] = await user.get_auth_state()
user_['auth_state'] = await self._user_from_orm(user).get_auth_state()
Copy link
Member

Choose a reason for hiding this comment

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

I see by this call to _user_from_orm that the above find_user really is required, so it should probably be put back.

@@ -734,6 +735,15 @@ async def auth_to_user(self, authenticated, user=None):
if admin is not None and admin != user.admin:
user.admin = admin
self.db.commit()
# add user to the given groups
if groups is not None:
Copy link
Member

Choose a reason for hiding this comment

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

👍

@eliaswimmer
Copy link
Author

As #3548 is merged, I close this PR.

@eliaswimmer eliaswimmer closed this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants