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

Implement JupyterHub 5.x sharing APIs in the hub client #224

Merged
merged 61 commits into from
May 8, 2024
Merged

Conversation

aktech
Copy link
Member

@aktech aktech commented Apr 9, 2024

Reference Issues or PRs

Implements #185 and part of #11

On top of: #248

What does this implement/fix?

Put a x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features not to work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

  • Did you test the pull request locally?
  • Did you add new tests?

Documentation

Access-centered content checklist

Text styling

  • The content is written with plain language (where relevant).
  • If there are headers, they use the proper header tags (with only one level-one header: H1 or # in markdown).
  • All links describe where they link to (for example, check the Nebari website).
  • This content adheres to the Nebari style guides.

Non-text content

  • All content is represented as text (for example, images need alt text, and videos need captions or descriptive transcripts).
  • If there are emojis, there are not more than three in a row.
  • Don't use flashing GIFs or videos.
  • If the content were to be read as plain text, it still makes sense, and no information is missing.

Any other comments?

Copy link

vercel bot commented Apr 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jhub-apps ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 2:10pm
jhub-apps-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 2:10pm

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

The code looks good to me, I left a few questions.

Comment on lines +134 to +143
url = f"/shares/{username}/{servername}"
if share_to_user:
data = {"user": share_to_user}
elif share_to_group:
data = {"group": share_to_group}
else:
raise ValueError("None of share_to_user or share_to_group provided")
share_with = share_to_group or share_to_user
logger.info(f"Sharing {username}/{servername} with {share_with}")
return requests.post(API_URL + url, headers=self._headers(), json=data)
Copy link
Member

Choose a reason for hiding this comment

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

Do we need some escaping here? My concern is, what if a user names their server ../../another-endpoint? Maybe it is safe because normalize_server_name should strip both . and /. Maybe all that needs to be done is having a test case to ensure no path traversal.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe it is safe because normalize_server_name should strip both . and /.

Yes, correct. I added tests for normalize_server_name.

jhub_apps/hub_client/hub_client.py Show resolved Hide resolved
Comment on lines 227 to 234
users = hclient.get_users()
user_names = [user["name"] for user in users]
groups = hclient.get_groups()
group_names = [group['name'] for group in groups]
# TODO: Filter users and groups based on what the user has access to share with
# parsed_scopes = parse_scopes(scopes)
return {
"users": user_names,
Copy link
Member

Choose a reason for hiding this comment

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

Does it makes sense to always filter the current user out as sharing with yourself does not have much utility?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good catch. Done.

Copy link
Member

@krassowski krassowski left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you!

Comment on lines +234 to +235
# TODO: Filter users and groups based on what the user has access to share with
# parsed_scopes = parse_scopes(scopes)
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 there is now #268 for this 👍

@aktech aktech merged commit 79b0288 into main May 8, 2024
25 checks passed
@aktech aktech deleted the share-apis branch May 26, 2024 16:48
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.

2 participants