diff options
| author | Rutger Broekhoff | 2023-12-30 22:26:56 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2023-12-30 22:26:56 +0100 |
| commit | b1d813a5b1f960b751b8dff5bdd7f6d1059949d0 (patch) | |
| tree | 8882f44b15ea41d9394da9e3f9fc1d95bbefbbca /cmd/git-lfs-authenticate | |
| parent | 42a2f9ce36240c28c729d605448dd12c5b6fc56c (diff) | |
| download | gitolfs3-b1d813a5b1f960b751b8dff5bdd7f6d1059949d0.tar.gz gitolfs3-b1d813a5b1f960b751b8dff5bdd7f6d1059949d0.zip | |
Add .git suffix to repo in href construction
Diffstat (limited to 'cmd/git-lfs-authenticate')
| -rw-r--r-- | cmd/git-lfs-authenticate/main.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/cmd/git-lfs-authenticate/main.go b/cmd/git-lfs-authenticate/main.go index 7a8a778..fc98246 100644 --- a/cmd/git-lfs-authenticate/main.go +++ b/cmd/git-lfs-authenticate/main.go | |||
| @@ -132,7 +132,7 @@ func main() { | |||
| 132 | die("expected 2 arguments (path, operation), got %d", len(os.Args)-1) | 132 | die("expected 2 arguments (path, operation), got %d", len(os.Args)-1) |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | repoPath := strings.TrimPrefix(strings.TrimSuffix(os.Args[1], ".git"), "/") | 135 | repo := strings.TrimPrefix(strings.TrimSuffix(os.Args[1], ".git"), "/") |
| 136 | operation := os.Args[2] | 136 | operation := os.Args[2] |
| 137 | if operation != "download" && operation != "upload" { | 137 | if operation != "download" && operation != "upload" { |
| 138 | die("expected operation to be upload or download, got %s", operation) | 138 | die("expected operation to be upload or download, got %s", operation) |
| @@ -179,10 +179,10 @@ func main() { | |||
| 179 | } | 179 | } |
| 180 | privateKey := ed25519.NewKeyFromSeed(seed) | 180 | privateKey := ed25519.NewKeyFromSeed(seed) |
| 181 | 181 | ||
| 182 | if !getGitoliteAccess(logger, reqID, repoPath, user, "R") { | 182 | if !getGitoliteAccess(logger, reqID, repo, user, "R") { |
| 183 | die("repository not found") | 183 | die("repository not found") |
| 184 | } | 184 | } |
| 185 | if operation == "upload" && !getGitoliteAccess(logger, reqID, repoPath, user, "W") { | 185 | if operation == "upload" && !getGitoliteAccess(logger, reqID, repo, user, "W") { |
| 186 | // User has read access but no write access | 186 | // User has read access but no write access |
| 187 | die("forbidden") | 187 | die("forbidden") |
| 188 | } | 188 | } |
| @@ -190,7 +190,7 @@ func main() { | |||
| 190 | expiresIn := time.Hour * 24 | 190 | expiresIn := time.Hour * 24 |
| 191 | claims := customClaims{ | 191 | claims := customClaims{ |
| 192 | Gitolfs3: gitolfs3Claims{ | 192 | Gitolfs3: gitolfs3Claims{ |
| 193 | Repository: repoPath, | 193 | Repository: repo, |
| 194 | Permission: operation, | 194 | Permission: operation, |
| 195 | }, | 195 | }, |
| 196 | RegisteredClaims: &jwt.RegisteredClaims{ | 196 | RegisteredClaims: &jwt.RegisteredClaims{ |
| @@ -215,7 +215,7 @@ func main() { | |||
| 215 | } | 215 | } |
| 216 | if repoHRefBase != nil { | 216 | if repoHRefBase != nil { |
| 217 | response.HRef = repoHRefBase.ResolveReference(&url.URL{ | 217 | response.HRef = repoHRefBase.ResolveReference(&url.URL{ |
| 218 | Path: path.Join(repoPath, "/info/lfs"), | 218 | Path: path.Join(repo+".git", "/info/lfs"), |
| 219 | }).String() | 219 | }).String() |
| 220 | } | 220 | } |
| 221 | json.NewEncoder(os.Stdout).Encode(response) | 221 | json.NewEncoder(os.Stdout).Encode(response) |