diff --git a/cmd/revad/svcs/httpsvcs/datasvc/get.go b/cmd/revad/svcs/httpsvcs/datasvc/get.go index 54898a2cd27..0ad534a5101 100644 --- a/cmd/revad/svcs/httpsvcs/datasvc/get.go +++ b/cmd/revad/svcs/httpsvcs/datasvc/get.go @@ -29,10 +29,8 @@ import ( func (s *svc) doGet(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - log := appctx.GetLogger(ctx) - + log := appctx.GetLogger(ctx) files, ok := r.URL.Query()["filename"] - if !ok || len(files[0]) < 1 { w.WriteHeader(http.StatusBadRequest) return diff --git a/cmd/revad/svcs/httpsvcs/iframeuisvc/iframeuisvc.go b/cmd/revad/svcs/httpsvcs/iframeuisvc/iframeuisvc.go index d437d355a09..d2ef6500646 100644 --- a/cmd/revad/svcs/httpsvcs/iframeuisvc/iframeuisvc.go +++ b/cmd/revad/svcs/httpsvcs/iframeuisvc/iframeuisvc.go @@ -20,10 +20,12 @@ package iframeuisvc import ( "net/http" + "strings" "github.com/cs3org/reva/cmd/revad/httpserver" "github.com/cs3org/reva/cmd/revad/svcs/httpsvcs" "github.com/cs3org/reva/pkg/appctx" + "github.com/cs3org/reva/pkg/user" "github.com/mitchellh/mapstructure" ) @@ -74,32 +76,25 @@ func getHandler() http.Handler { } func doOpen(w http.ResponseWriter, r *http.Request) { - log := appctx.GetLogger(r.Context()) - filename := r.URL.Path - html := ` - - - - - - - - - - - -
- - - ` - if _, err := w.Write([]byte(html)); err != nil { - log.Err(err).Msg("error writing response") + ctx := r.Context() + log := appctx.GetLogger(ctx) + + u, ok := user.ContextGetUser(ctx) + if !ok { + log.Error().Msg("error getting user from context") + w.WriteHeader(http.StatusInternalServerError) + return + } + + filename := strings.TrimPrefix(r.URL.Path, "/") + + tokens := r.URL.Query()["access_token"] + token := tokens[0] + + responseString := `https://root.cern/js/latest/?file=http://localhost:9998/data?filename=/` + u.Username + `/` + filename + `&access_token=` + token + _, err := w.Write([]byte(responseString)) + if err != nil { + log.Error().Err(err).Msg("can't write to response") + w.WriteHeader(http.StatusInternalServerError) } }