require auth for ui, search, jsonsign, sync handlers

Change-Id: I2fec6688af87344c09fbe9099bded230efa745c7
This commit is contained in:
Brad Fitzpatrick 2011-12-10 17:18:19 -08:00
parent b16d440543
commit be45ed886b
2 changed files with 16 additions and 2 deletions

View File

@ -1 +1 @@
6g version release.r60.3 9959
6g version release.r60.3 9516

View File

@ -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 {