Logs
Patchsets
Patchset ps-33
feat(pgs): tunnel default to requester username if no username provided
Eric Bower
pgs/api.go
+3
-0
pgs/tunnel.go
+12
-7
feat(pgs): tunnel default to requester username if no username provided
pgs/api.go
link
+3
-0
+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
+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")