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

Add GnuPG Support to sign git commits #170

Closed
strausmann opened this issue Jan 21, 2022 · 26 comments · Fixed by #171
Closed

Add GnuPG Support to sign git commits #170

strausmann opened this issue Jan 21, 2022 · 26 comments · Fixed by #171
Assignees
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main

Comments

@strausmann
Copy link
Contributor

strausmann commented Jan 21, 2022

Problem this feature will solve

The signing of Git commits currently has to be set up again each time the workspace is restarted.

Background

Restarting the workspace does not preserve the local information of the workspace, thus the GPG Privatekey and the Git Config are not preserved.

Proposed Solution

With the start of the workspace, the Git configuration should want to automatically sign each commit and the GnuPG private key is imported into the workspace. So that with a Git commit only the password of the GPG key is requested and the commit is signed with it.

Constraints and Assumptions

  • GPG support should only be set up if GPG_KEY and GPG_KEY_ID are stored in the Gitpod environments.
  • The GPG private key should be Base64 encoded in the GitPod environments.
  • GPG signed commits will not be marked as verified in the github UI if the email ~/.gitconfig doesnt match that of the GPG key.

Alternatives or Workarounds

Since this is not a rarely relevant feature, a project-based implementation is less likely to be considered if necessary.

Additional context

Add any other context or screenshots about the feature request here.

@apolopena
Copy link
Owner

@strausmann For documentation and testing can you give an example of the proper values for $GNUPG_KEY and $GNUPG_SIGNING_KEY?

@apolopena
Copy link
Owner

I merged in your changes to the development branch and enhanced them, now I would like to test and document this great feature.

@apolopena
Copy link
Owner

Depends on #176

apolopena added a commit that referenced this issue Jan 22, 2022
@apolopena
Copy link
Owner

apolopena commented Jan 22, 2022

@strausmann ready to test in the development branch
https://gitpod.io/#/https://github.com/apolopena/gitpod-laravel-starter/tree/development

Please test on multiple workspace restarts to be safe.

@strausmann
Copy link
Contributor Author

Could be used successfully even after several restarts of the workspace.

image

@apolopena
Copy link
Owner

Awesome. Perhaps we should quiet the gpg stdout and only show stderr since we have so much output already. We report on SUCCESS or ERROR already. What do you think?

@strausmann
Copy link
Contributor Author

I like, I had also already considered

@apolopena
Copy link
Owner

Great. I just added that in blind. Test if you like.

@strausmann
Copy link
Contributor Author

Does not work as expected 3614991

@apolopena
Copy link
Owner

Ok please try again

@strausmann
Copy link
Contributor Author

Looks better...

image

@strausmann
Copy link
Contributor Author

image

@apolopena
Copy link
Owner

I am pretty sure this existed before my fix for supressing output. Please revert those fixes and run git log --show-signature -1 again to verify.

@strausmann
Copy link
Contributor Author

All good, this was the output of git log --show-signature -1
just wanted to clarify that now signing works again.

@apolopena
Copy link
Owner

oh ok, haha. It looked like a failure with that warning but I take it that is because the key you are testing with is just a dummy. If you used your true key would the warning go away?

@apolopena
Copy link
Owner

Yeah so the last thing on the list before release is #176. Please see my last comment.

@apolopena
Copy link
Owner

oh yeah the intellisense feature needs to be documented in the README as well. I will add that to #176

@strausmann
Copy link
Contributor Author

git log --show-signature -1

No, even with my own key the warning is not gone, because after importing the key, you would still have to set it trusted.

You would have to execute an edit-key interactively to trust the key.

But everything ok. You still need the passphrase for the private key anyway.

@apolopena
Copy link
Owner

You would have to execute an edit-key interactively to trust the key.

Can you give me this or a link that shows how its done so I can put it in the documentation?

@strausmann
Copy link
Contributor Author

@apolopena apolopena added in-development Bug or feature is currently being worked on and removed in-dev-qa labels Jan 23, 2022
@apolopena
Copy link
Owner

Renaming GNUPG_SIGNING_KEY to GPG_KEY_ID and GNUPG_KEY to GPG_KEY, will document this in #176

apolopena added a commit that referenced this issue Jan 24, 2022
@apolopena apolopena added in-dev-qa and removed in-development Bug or feature is currently being worked on labels Jan 24, 2022
apolopena added a commit that referenced this issue Jan 24, 2022
@apolopena
Copy link
Owner

GPG Key for git commit signing is implemented properly and logged however pushes to remote still show up as unverified.

@apolopena
Copy link
Owner

This is related to the fact that a GPG key can have an email address that doesn't match the git commiters address such as in the case where a github no-reply email address is used such as 3060702+apolopena@users.noreply.github.com

@apolopena
Copy link
Owner

apolopena commented Jan 24, 2022

I will add support for a third environment variable: GPG_MATCH_GIT_TO_EMAIL
The value should be set to the email that your GPG key uses.
Setting this environment variable will set git config --global user.email $GPG_MATCH_GIT_TO_EMAIL

@apolopena
Copy link
Owner

I will add support for a fourth environment variable: $GPG_AUTO_ULTIMATE_TRUST
If the value is set to yes or YES then the GPG_KEY with GPG_KEY_ID will be programatically given ultimate trust.

apolopena added a commit that referenced this issue Jan 25, 2022
@apolopena apolopena added in-development Bug or feature is currently being worked on and removed in-dev-qa labels Jan 25, 2022
@strausmann
Copy link
Contributor Author

@apolopena
Perfect... thank you

image

@apolopena apolopena added in-dev-qa passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main and removed in-development Bug or feature is currently being worked on in-dev-qa labels Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants