dashboard / send / refactor(sftp): print errors from server to client #17 rss

closed · opened on 2024-08-20T03:19:05Z by erock
Help
# add changes to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add 17
# add review to patch request
git format-patch main --stdout | ssh pr.pico.sh pr add --review 17
# remove patchset
ssh pr.pico.sh ps rm ps-x
# checkout all patches
ssh pr.pico.sh pr print 17 | git am -3
# print a diff between the last two patches in a patch request
ssh pr.pico.sh pr diff 17
# accept PR
ssh pr.pico.sh pr accept 17
# close PR
ssh pr.pico.sh pr close 17

Logs

erock created pr with ps-33 on 2024-08-19T13:48:20Z
erock changed status on 2024-12-20T18:23:14Z {"status":"closed"}

Patchsets

ps-33 by erock on 2024-08-19T13:48:20Z

feat(pgs): tunnel default to requester username if no username provided

pgs/api.go link
+3 -0
 1diff --git a/pgs/api.go b/pgs/api.go
 2index f73c5eb..d3c39df 100644
 3--- a/pgs/api.go
 4+++ b/pgs/api.go
 5@@ -372,6 +372,9 @@ func ServeAsset(fname string, opts *storage.ImgProcessOpts, fromImgs bool, hasPe
 6 	st := shared.GetStorage(r)
 7 	logger := shared.GetLogger(r)
 8 
 9+	fmt.Println("===")
10+	fmt.Println(subdomain)
11+	fmt.Println("===")
12 	props, err := getProjectFromSubdomain(subdomain)
13 	if err != nil {
14 		logger.Info(err.Error(), "subdomain", subdomain, "filename", fname)
pgs/tunnel.go link
+12 -7
 1diff --git a/pgs/tunnel.go b/pgs/tunnel.go
 2index e9bf24a..694fa5a 100644
 3--- a/pgs/tunnel.go
 4+++ b/pgs/tunnel.go
 5@@ -57,6 +57,18 @@ func createHttpHandler(apiConfig *shared.ApiConfig) CtxHttpBridge {
 6 			return http.HandlerFunc(shared.UnauthorizedHandler)
 7 		}
 8 
 9+		requester, _ := dbh.FindUserForKey("", pubkeyStr)
10+		if requester != nil {
11+			log = log.With(
12+				"requester", requester.Name,
13+			)
14+		}
15+
16+		// assume no username provided
17+		if props.Username == props.ProjectName {
18+			props.Username = requester.Name
19+		}
20+
21 		owner, err := dbh.FindUserForName(props.Username)
22 		if err != nil {
23 			log.Error(err.Error())
24@@ -72,13 +84,6 @@ func createHttpHandler(apiConfig *shared.ApiConfig) CtxHttpBridge {
25 			return http.HandlerFunc(shared.UnauthorizedHandler)
26 		}
27 
28-		requester, _ := dbh.FindUserForKey("", pubkeyStr)
29-		if requester != nil {
30-			log = log.With(
31-				"requester", requester.Name,
32-			)
33-		}
34-
35 		// impersonation logic
36 		if asUser != "" {
37 			isAdmin := dbh.HasFeatureForUser(requester.ID, "admin")