Skip to content

Allow pushmirror to use publickey authentication #18835

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

Closed
wants to merge 59 commits into from

Conversation

Gusted
Copy link
Contributor

@Gusted Gusted commented Feb 20, 2022

  • Adds the option to use let the pushmirror use publickey authentication for push actions instead of using user:password authentication. The Publickey algorithm uses for this is ed25519, and is saved in OpenSSH's format so it can be used directly with git.
  • Resolves Push mirror using public key authorization #18159

image

@wxiaoguang

This comment was marked as outdated.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 20, 2022
@Gusted
Copy link
Contributor Author

Gusted commented Feb 20, 2022

@wxiaoguang I've changed my comment to reflect a more accurate representation. Sorry for the confusion.

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Feb 20, 2022

No need to say sorry .... 😊 I just hope most people can realize the fact, and make Gitea frontend get rid of the current nobody-cares situation.

@Gusted Gusted marked this pull request as ready for review February 20, 2022 15:05
@Gusted
Copy link
Contributor Author

Gusted commented Feb 20, 2022

Ready for review... I'm not sure how to handle the UI to display the long ssh key.

@Gusted Gusted added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Feb 20, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 20, 2022

Codecov Report

Merging #18835 (801741d) into main (a3d55ac) will increase coverage by 0.01%.
The diff coverage is 60.87%.

@@            Coverage Diff             @@
##             main   #18835      +/-   ##
==========================================
+ Coverage   46.93%   46.95%   +0.01%     
==========================================
  Files         977      979       +2     
  Lines      135302   135609     +307     
==========================================
+ Hits        63508    63672     +164     
- Misses      64012    64132     +120     
- Partials     7782     7805      +23     
Impacted Files Coverage Δ
cmd/dump.go 0.67% <ø> (ø)
models/repo/pushmirror.go 78.00% <ø> (ø)
modules/context/package.go 48.27% <0.00%> (-8.49%) ⬇️
modules/lfs/content_store.go 74.66% <ø> (+4.66%) ⬆️
modules/packages/container/metadata.go 76.92% <ø> (ø)
routers/web/org/setting.go 0.00% <0.00%> (ø)
routers/web/repo/packages.go 0.00% <0.00%> (ø)
routers/web/repo/setting.go 16.70% <0.00%> (-0.23%) ⬇️
routers/web/user/setting/account.go 25.65% <0.00%> (-0.12%) ⬇️
routers/web/user/setting/profile.go 35.36% <0.00%> (-0.44%) ⬇️
... and 48 more

Help us with your feedback. Take ten seconds to tell us how you rate us.

@Gusted Gusted force-pushed the publickey-auth-push-mirror branch from b0e7a61 to f3bbdcc Compare February 20, 2022 15:24
@Gusted Gusted force-pushed the publickey-auth-push-mirror branch from f3bbdcc to af81b21 Compare February 20, 2022 15:25
@Gusted
Copy link
Contributor Author

Gusted commented Feb 20, 2022

Force-pushed twice, because git was being funny.

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Aug 22, 2022
@@ -26,6 +27,10 @@ type PushMirror struct {
Repo *Repository `xorm:"-"`
RemoteName string

// A keypair formatted in OpenSSH format.
PublicKey string
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be a TEXT field on MySQL which is potentially too small for an RSA key - how big is the potential representation for ED25519 keys?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I once run a script with the old code in modules/crypto/ed25519.go to generate a few million private keys and get their max length. IIRC it was 387, so I just got at 400 to be safe.

Public keys are: ssh-ed25519 + base64 of the ssh's marshaled of the public key bytes + new line And should result in a max of 81 bytes per the analysis of the code (we likely should have a test that verifies these lengths)

Copy link
Member

Choose a reason for hiding this comment

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

Might still want to enlarge it now to accomodate future key formats. There's no need to define database fields so tightly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not able to guess future key formats. I prefer to just limit it to Ed25519 signatures and only add other signatures scheme if there's a need for them.

Copy link
Member

Choose a reason for hiding this comment

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

If we enlarge now, it saves us from the pain of a future migration. So, unless this is a critical performance code path where there are indexing benefits by using the smaller type, I would enlarge.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright then, I give in. What would be a good size to use here?

Copy link
Member

Choose a reason for hiding this comment

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

Correct, MySQL TEXT should be limited to 65535 bytes, which seems plenty. So this is LGTM.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 20, 2022
@lunny
Copy link
Member

lunny commented Oct 20, 2022

Please resolve the conflicts.

@lunny lunny modified the milestones: 1.18.0, 1.19.0 Oct 23, 2022
@elipsion
Copy link

@Gusted Is this PR abandoned? Do you need any help finishing up the merge conflicts?

@lunny lunny removed this from the 1.19.0 milestone Feb 1, 2023
@Gusted
Copy link
Contributor Author

Gusted commented Feb 9, 2023

@Gusted Is this PR abandoned? Do you need any help finishing up the merge conflicts?

No, the merge conflicts aren't the problem. Rather that I forgot that Git-LFS exists, which is way harder to support with SSH. I'm not knowledgeable enough about LFS to even try add support for it.

@elipsion
Copy link

No, the merge conflicts aren't the problem. Rather that I forgot that Git-LFS exists, which is way harder to support with SSH. I'm not knowledgeable enough about LFS to even try add support for it.

Would it be possible to implement push mirrors without support for Git-LFS and leave that feature for the future? There are a fair number of repositories that doesn't require it, so the implementation would not be wasted.

@wxiaoguang wxiaoguang added the status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR label May 4, 2023
@puni9869
Copy link
Member

puni9869 commented Sep 1, 2023

👀

@denyskon
Copy link
Member

@Gusted Are you still willing to work on this PR? I think this feature would be a great addition even without Git LFS support. I see that you suggested to force HTTP auth for LFS-enabled repos - I think this would be an acceptable approach.

If you still want to continue with this PR, please resolve merge conflicts and maybe we could merge it soon.

@denyskon denyskon added the issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail label Jan 15, 2024
@philip-peterson
Copy link
Contributor

philip-peterson commented Aug 3, 2024

@Gusted Any way I can help? I am also interested in pushing this through to the finish line. I know a lot about LFS.

@denyskon
Copy link
Member

denyskon commented Aug 4, 2024

@philip-peterson AFAIK this contributor is now rather more active over at Forgejo. As there was no response in a while, we can consider this PR as abandoned.

As this feature still would be a valuable addition, it would be great if you or somebody else could take over this PR.

@techknowlogick
Copy link
Member

I'll close this PR for those reasons. Im refactoring other code areas that might make this easier anyway

@go-gitea go-gitea locked and limited conversation to collaborators Aug 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/needs-feedback For bugs, we need more details. For features, the feature must be described in more detail lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. status/blocked This PR cannot be merged yet, i.e. because it depends on another unmerged PR type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push mirror using public key authorization