cmd/uplink: tighter linksharing security
when a user runs `uplink share`, they get a bunch of results back, given their configuration and existing access. one of the results is a URL for in-browser sharing and hosting of the file. first off, we want to make sure this URL is read only. we want to avoid a situation where someone post this URL to some public location, not realizing the access allows writes or deletes. if a user really wants a URL with write/delete access, they can construct it themselves. secondly, we want to make sure the url is sharing a single path or path prefix. having a url for multiple paths/path prefixes indepedently again can be constructed of course, but should not be the default behavior Change-Id: I2ca2ebeea9f1c7d4bfbd7a437a32dc7a3b2a32cc
This commit is contained in:
parent
6cc7fd5f31
commit
2bd9067ad5
@ -22,10 +22,10 @@ import (
|
||||
|
||||
var shareCfg struct {
|
||||
DisallowReads bool `default:"false" help:"if true, disallow reads" basic-help:"true"`
|
||||
DisallowWrites bool `default:"false" help:"if true, disallow writes" basic-help:"true"`
|
||||
DisallowWrites bool `default:"false" help:"if true, disallow writes. see also readonly" basic-help:"true"`
|
||||
DisallowLists bool `default:"false" help:"if true, disallow lists" basic-help:"true"`
|
||||
DisallowDeletes bool `default:"false" help:"if true, disallow deletes" basic-help:"true"`
|
||||
Readonly bool `default:"false" help:"implies disallow_writes and disallow_deletes" basic-help:"true"`
|
||||
DisallowDeletes bool `default:"false" help:"if true, disallow deletes. see also readonly" basic-help:"true"`
|
||||
Readonly bool `default:"true" help:"implies disallow_writes and disallow_deletes. you must specify --readonly=false if you don't want this" basic-help:"true"`
|
||||
Writeonly bool `default:"false" help:"implies disallow_reads and disallow_lists" basic-help:"true"`
|
||||
NotBefore string `help:"disallow access before this time (e.g. '+2h', '2020-01-02T15:01:01-01:00')" basic-help:"true"`
|
||||
NotAfter string `help:"disallow access after this time (e.g. '+2h', '2020-01-02T15:01:01-01:00')" basic-help:"true"`
|
||||
@ -146,7 +146,7 @@ func shareMain(cmd *cobra.Command, args []string) (err error) {
|
||||
fmt.Println("=========== SERIALIZED ACCESS WITH THE ABOVE RESTRICTIONS TO SHARE WITH OTHERS ===========")
|
||||
fmt.Println("Access :", newAccessData)
|
||||
|
||||
if len(shareCfg.AllowedPathPrefix) == 1 {
|
||||
if len(shareCfg.AllowedPathPrefix) == 1 && !permission.AllowUpload && !permission.AllowDelete {
|
||||
fmt.Println("=========== BROWSER URL ==================================================================")
|
||||
p, err := fpath.New(shareCfg.AllowedPathPrefix[0])
|
||||
if err != nil {
|
||||
@ -156,10 +156,6 @@ func shareMain(cmd *cobra.Command, args []string) (err error) {
|
||||
url.PathEscape(newAccessData),
|
||||
url.PathEscape(p.Bucket()),
|
||||
url.PathEscape(p.Path())))
|
||||
} else {
|
||||
fmt.Println("=========== BROWSER URL PREFIX ===========================================================")
|
||||
fmt.Println("URL :", fmt.Sprintf("%s/%s", shareCfg.BaseURL,
|
||||
url.PathEscape(newAccessData)))
|
||||
}
|
||||
|
||||
if shareCfg.ExportTo != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user