-
-
Notifications
You must be signed in to change notification settings - Fork 6k
SSH Push/Pull Mirroring & Migrations #35089
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
base: main
Are you sure you want to change the base?
Conversation
Could the table |
As-in, have the data be duplicated in two tables? I'm not sure what your suggestion is, could you give more details? |
I mean the table |
// RegenerateUserSSHKeypair regenerates an SSH keypair for the given owner | ||
func RegenerateUserSSHKeypair(ctx context.Context, ownerID int64) (*UserSSHKeypair, error) { | ||
var keypair *UserSSHKeypair | ||
err := db.WithTx(ctx, func(ctx context.Context) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use db.WithTx2
instead now.
@@ -384,7 +384,7 @@ func prepareMigrationTasks() []*migration { | |||
newMigration(319, "Add ExclusiveOrder to Label table", v1_24.AddExclusiveOrderColumnToLabelTable), | |||
newMigration(320, "Migrate two_factor_policy to login_source table", v1_24.MigrateSkipTwoFactor), | |||
|
|||
// Gitea 1.24.0 ends at database version 321 | |||
// Gitea 1.24.0 ends at migration ID number 320 (database version 321) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated change now.
@@ -1687,6 +1692,11 @@ func Routes() *web.Router { | |||
m.Delete("", org.UnblockUser) | |||
}) | |||
}, reqToken(), reqOrgOwnership()) | |||
|
|||
m.Group("/mirror-ssh-key", func() { | |||
m.Get("", reqToken(), reqOrgMembership(), org.GetMirrorSSHKey) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Permissions to create repository is necessary?
// RegenerateSSHKeypairForUser regenerates the SSH keypair for a user | ||
func RegenerateSSHKeypairForUser(ctx context.Context, userID int64) (*repo_model.UserSSHKeypair, error) { | ||
log.Info("Regenerating SSH keypair for user %d", userID) | ||
return repo_model.RegenerateUserSSHKeypair(ctx, userID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wrap seems unnecessary.
} | ||
|
||
// RegenerateSSHKeypairForOrg regenerates the SSH keypair for an organization | ||
func RegenerateSSHKeypairForOrg(ctx context.Context, orgID int64) (*repo_model.UserSSHKeypair, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same as above
|
||
// GetOrCreateSSHKeypairForUser gets or creates an SSH keypair for the given user | ||
func GetOrCreateSSHKeypairForUser(ctx context.Context, userID int64) (*repo_model.UserSSHKeypair, error) { | ||
return ssh_module.GetOrCreateSSHKeypairForUser(ctx, userID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all these functions could be moved from ssh_module to this package.
And maybe it's better to put all these SSH keys into the same table and manage them together. So that some SSH keys could be used in multiple places with a permission setting. And it will also be easier to invoke them if necessary. |
Why and how? Can you show a real world example that how these keys would be managed and used together in the future? The auto-generated keys are managed by Gitea itself, they are not the same as user's SSH keys for SSH access or sign. If no real world case, then it is an over-design. |
Add SSH for push/pull mirrors and repo migrations.
Each User/Org gets their own public/private key, and they can rotate/regen it as they please. Users can now use
ssh://[email protected]/go-gitea/gitea.git
as a clone source.Fixes: #26321