mirror of
https://github.com/mickael-kerjean/filestash
synced 2025-12-06 08:22:24 +01:00
fix (#469): allow cross domain iframe
This commit is contained in:
parent
cb8bf3ace7
commit
629a80c836
3 changed files with 19 additions and 1 deletions
|
|
@ -92,6 +92,12 @@ func NewConfiguration() Configuration {
|
|||
FormElement{Name: "redirect", Type: "string", Placeholder: "redirection URL", Description: "When set, shared links will perform a redirection to another link. Example: https://example.com?full_path={{path}}"},
|
||||
},
|
||||
},
|
||||
Form{
|
||||
Title: "protection",
|
||||
Elmnts: []FormElement{
|
||||
FormElement{Name: "iframe", Type: "text", Default: "", Description: "list of domains who can use the application from an iframe. eg: https://www.filestash.app http://example.com"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Form{
|
||||
|
|
|
|||
|
|
@ -102,7 +102,13 @@ func SessionAuthenticate(ctx App, res http.ResponseWriter, req *http.Request) {
|
|||
MaxAge: 60 * Config.Get("general.cookie_timeout").Int(),
|
||||
Path: COOKIE_PATH,
|
||||
HttpOnly: true,
|
||||
SameSite: http.SameSiteStrictMode,
|
||||
Secure: true,
|
||||
SameSite: func() http.SameSite {
|
||||
if Config.Get("features.protection.iframe").String() != "" {
|
||||
return http.SameSiteNoneMode
|
||||
}
|
||||
return http.SameSiteStrictMode
|
||||
}(),
|
||||
})
|
||||
if end == len(obfuscate) {
|
||||
break
|
||||
|
|
|
|||
|
|
@ -48,6 +48,12 @@ func IndexHeaders(fn func(App, http.ResponseWriter, *http.Request)) func(ctx App
|
|||
cspHeader += "worker-src 'self' blob:; "
|
||||
cspHeader += "form-action 'self'; base-uri 'self'; "
|
||||
cspHeader += "frame-src 'self'; "
|
||||
if ori := Config.Get("features.protection.iframe").String(); ori == "" {
|
||||
cspHeader += "frame-ancestors 'none';"
|
||||
header.Set("X-Frame-Options", "DENY")
|
||||
} else {
|
||||
cspHeader += fmt.Sprintf("frame-ancestors %s;", ori)
|
||||
}
|
||||
header.Set("Content-Security-Policy", cspHeader)
|
||||
fn(ctx, res, req)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue