Skip to content

Conversation

@nheeb
Copy link
Contributor

@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 'd.pape@hzdr.de' 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.

@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. 🤦🏻‍♂️

nheeb and others added 4 commits September 4, 2024 12:39
Co-authored-by: David Pape <d.pape@hzdr.de>
Co-authored-by: David Pape <d.pape@hzdr.de>
Co-authored-by: David Pape <d.pape@hzdr.de>
Co-authored-by: David Pape <d.pape@hzdr.de>
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.

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").

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.

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 🤷🏻‍♂️

@nheeb nheeb requested a review from poikilotherm November 6, 2024 09:17
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.

Looks good to me! A good foundation to continue with! Good job @nheeb

@poikilotherm poikilotherm merged commit dc0f625 into develop Dec 9, 2024
5 checks passed
@poikilotherm poikilotherm deleted the feature/init-command branch December 9, 2024 20:35
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.

4 participants