mirror of https://github.com/perkeep/perkeep.git
require auth for ui, search, jsonsign, sync handlers
Change-Id: I2fec6688af87344c09fbe9099bded230efa745c7
This commit is contained in:
parent
b16d440543
commit
be45ed886b
|
@ -1 +1 @@
|
|||
6g version release.r60.3 9959
|
||||
6g version release.r60.3 9516
|
||||
|
|
|
@ -256,7 +256,21 @@ func (hl *handlerLoader) setupHandler(prefix string) {
|
|||
h.prefix, h.htype, err)
|
||||
}
|
||||
hl.handler[prefix] = hh
|
||||
hl.installer.Handle(prefix, &httputil.PrefixHandler{prefix, hh})
|
||||
var wrappedHandler http.Handler = &httputil.PrefixHandler{prefix, hh}
|
||||
if handerTypeWantsAuth(h.htype) {
|
||||
wrappedHandler = auth.Handler{wrappedHandler}
|
||||
}
|
||||
hl.installer.Handle(prefix, wrappedHandler)
|
||||
}
|
||||
|
||||
func handerTypeWantsAuth(handlerType string) bool {
|
||||
// TODO(bradfitz): ask the handler instead? This is a bit of a
|
||||
// weird spot for this policy maybe?
|
||||
switch handlerType {
|
||||
case "ui", "search", "jsonsign", "sync":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
|
Loading…
Reference in New Issue