aboutsummaryrefslogtreecommitdiff
path: root/ssh_handle_receive_pack.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-02-19 21:19:15 +0800
committerRunxi Yu <me@runxiyu.org>2025-02-19 21:19:15 +0800
commit7fb71b36ad50153f6e05d066284688d1128a7a21 (patch)
treefbbcc33fdeeb43b1c495baba122a5be845b61ad9 /ssh_handle_receive_pack.go
parentssh/recv, users, schema: Create pubkey_only users (diff)
downloadforge-7fb71b36ad50153f6e05d066284688d1128a7a21.tar.gz
forge-7fb71b36ad50153f6e05d066284688d1128a7a21.tar.zst
forge-7fb71b36ad50153f6e05d066284688d1128a7a21.zip
ssh/recv, hooks: Create MRs on push, reject pushes to others' MRs
Diffstat (limited to 'ssh_handle_receive_pack.go')
-rw-r--r--ssh_handle_receive_pack.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/ssh_handle_receive_pack.go b/ssh_handle_receive_pack.go
index 293bb36..8803151 100644
--- a/ssh_handle_receive_pack.go
+++ b/ssh_handle_receive_pack.go
@@ -15,13 +15,15 @@ type pack_to_hook_t struct {
pubkey string
direct_access bool
repo_path string
+ user_id int
+ repo_id int
}
var pack_to_hook_by_cookie = cmap.Map[string, pack_to_hook_t]{}
// ssh_handle_receive_pack handles attempts to push to repos.
func ssh_handle_receive_pack(session glider_ssh.Session, pubkey string, repo_identifier string) (err error) {
- repo_path, direct_access, contrib_requirements, user_type, err := get_repo_path_perms_from_ssh_path_pubkey(session.Context(), repo_identifier, pubkey)
+ repo_id, repo_path, direct_access, contrib_requirements, user_type, user_id, err := get_repo_path_perms_from_ssh_path_pubkey(session.Context(), repo_identifier, pubkey)
if err != nil {
return err
}
@@ -41,7 +43,7 @@ func ssh_handle_receive_pack(session glider_ssh.Session, pubkey string, repo_ide
return errors.New("You need to have an SSH public key to push to this repo.")
}
if user_type == "" {
- user_id, err := add_user_ssh(session.Context(), pubkey)
+ user_id, err = add_user_ssh(session.Context(), pubkey)
if err != nil {
return err
}
@@ -63,6 +65,8 @@ func ssh_handle_receive_pack(session glider_ssh.Session, pubkey string, repo_ide
pubkey: pubkey,
direct_access: direct_access,
repo_path: repo_path,
+ user_id: user_id,
+ repo_id: repo_id,
})
defer pack_to_hook_by_cookie.Delete(cookie)
// The Delete won't execute until proc.Wait returns unless something