aboutsummaryrefslogtreecommitdiff
path: root/ssh_utils.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-06 15:17:57 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-06 20:07:48 +0800
commit8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0 (patch)
treea2f33fccac42b554b1176741d00c1d0cd2d0dceb /ssh_utils.go
parentsql: Add purge and test scripts (diff)
downloadforge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.tar.gz
forge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.tar.zst
forge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.zip
*: Support subgroups via SQL recursion
Diffstat (limited to '')
-rw-r--r--ssh_utils.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/ssh_utils.go b/ssh_utils.go
index 0ec2065..d40facf 100644
--- a/ssh_utils.go
+++ b/ssh_utils.go
@@ -16,7 +16,7 @@ import (
var err_ssh_illegal_endpoint = errors.New("illegal endpoint during SSH access")
-func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path string, ssh_pubkey string) (group_name string, repo_name string, repo_id int, repo_path string, direct_access bool, contrib_requirements string, user_type string, user_id int, err error) {
+func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path string, ssh_pubkey string) (group_path []string, repo_name string, repo_id int, repo_path string, direct_access bool, contrib_requirements string, user_type string, user_id int, err error) {
var segments []string
var separator_index int
var module_type, module_name string
@@ -27,12 +27,12 @@ func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path stri
var err error
segments[i], err = url.PathUnescape(segment)
if err != nil {
- return "", "", 0, "", false, "", "", 0, err
+ return []string{}, "", 0, "", false, "", "", 0, err
}
}
if segments[0] == ":" {
- return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
+ return []string{}, "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
}
separator_index = -1
@@ -48,21 +48,21 @@ func get_repo_path_perms_from_ssh_path_pubkey(ctx context.Context, ssh_path stri
switch {
case separator_index == -1:
- return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
+ return []string{}, "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
case len(segments) <= separator_index+2:
- return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
+ return []string{}, "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
}
- group_name = segments[0]
+ group_path = segments[:separator_index]
module_type = segments[separator_index+1]
module_name = segments[separator_index+2]
repo_name = module_name
switch module_type {
case "repos":
- _1, _2, _3, _4, _5, _6, _7 := get_path_perm_by_group_repo_key(ctx, group_name, module_name, ssh_pubkey)
- return group_name, repo_name, _1, _2, _3, _4, _5, _6, _7
+ _1, _2, _3, _4, _5, _6, _7 := get_path_perm_by_group_repo_key(ctx, group_path, module_name, ssh_pubkey)
+ return group_path, repo_name, _1, _2, _3, _4, _5, _6, _7
default:
- return "", "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
+ return []string{}, "", 0, "", false, "", "", 0, err_ssh_illegal_endpoint
}
}