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

Feature/init command #273

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open

Feature/init command #273

wants to merge 38 commits into from

Conversation

nheeb
Copy link

@nheeb nheeb commented Sep 3, 2024

The init command is now working with Oauth. Zenodo Oauth saves the refresh token in the secret and deposit can now use a refresh token to get an access token.

Copy link
Contributor

@zyzzyxdonta zyzzyxdonta left a comment

Choose a reason for hiding this comment

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

I had a quick first look at this and wrote some comments. :-)

Some more that don't fit in the code:

  • The Zenodo oauth application says "Application 'hermes-init-oauth' by '' wants permission to access your '[email protected]' account." It would be nice if this was the hermes mailbox address instead of your private one.
  • The same for GitHub which currently says "hermes-init-oauth by nheeb". Maybe the softwarepub group can be used here?
  • During GitHub OAuth, I run into an error. Afterwards the CLI was stuck.
An error occurred during execution of init
ERROR:hermes.cli:An error occurred during execution of init
DEBUG:hermes.cli:Original exception was: Failed to retrieve public key: 404 {"message":"Not Found","documentation_url":"https://docs.github.com/rest/actions/secrets#get-a-repository-public-key","status":"404"}

Unfortunately, I'm clueless about OAuth, so I have no idea what is going wrong.

src/hermes/commands/init/github_permissions.py Outdated Show resolved Hide resolved
src/hermes/commands/init/github_permissions.py Outdated Show resolved Hide resolved
src/hermes/commands/init/github_secrets.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_github.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_zenodo.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_github.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_zenodo.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@zyzzyxdonta
Copy link
Contributor

Oh I see. I got a 404 because I gave a random git remote URI that doesn't exist but the code actually accesses my repo. 🤦🏻‍♂️

Copy link
Member

@poikilotherm poikilotherm left a comment

Choose a reason for hiding this comment

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

Overall this is a very good start. I agree with all of the points from @zyzzyxdonta and added some more 🙈

@nheeb I also noticed flake8 is unhappy. You can execute it locally using poetry run task flake8 with our configuration.

src/hermes/commands/init/__init__.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/github_permissions.py Outdated Show resolved Hide resolved
src/hermes/commands/init/github_secrets.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_github.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_zenodo.py Outdated Show resolved Hide resolved
src/hermes/commands/init/tmp_hermes_github_to_zenodo.yml Outdated Show resolved Hide resolved
src/hermes/commands/init/github_permissions.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_zenodo.py Outdated Show resolved Hide resolved
if line.startswith("*"):
info.current_branch = line.split()[1].strip()
break
info.uses_github = "github" in info.git_remote_url
Copy link
Contributor

Choose a reason for hiding this comment

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

info.git_remote_url.startswith("https://github.com") would be safest (or use urlparse and check netloc == "github.com").

src/hermes/commands/init/slim_click.py Outdated Show resolved Hide resolved
src/hermes/commands/init/slim_click.py Outdated Show resolved Hide resolved
src/hermes/commands/cli.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
import hermes.commands.init.slim_click as sc


class HermesInitFolderInfo:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong opinion on where this class should be. However, I would make it a dataclass if it doesn't have any functionality.

src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zyzzyxdonta zyzzyxdonta left a comment

Choose a reason for hiding this comment

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

Overall, I think this looks pretty good. Just some small suggestions, nothing critical.

I'm still not happy with the oauth client details in the code because malicious actors might reuse them for their activities and they would show up as "hermes" when logging in. But if this is the only way to do it, then I guess there's no choice 🤷🏻‍♂️

src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/base.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_process.py Outdated Show resolved Hide resolved
src/hermes/commands/init/oauth_process.py Outdated Show resolved Hide resolved
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.

3 participants