Cleanup and minor fix for digest

This commit is contained in:
Dipankar Sarkar 2014-12-11 17:48:08 +05:30
parent 6798f193fd
commit f9b1546367
2 changed files with 6 additions and 19 deletions

View File

@ -93,6 +93,7 @@ func main() {
http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect)) http.Handle("/", http.RedirectHandler(pages.ContainersPage, http.StatusTemporaryRedirect))
var authenticated bool = false var authenticated bool = false
// Setup the authenticator object // Setup the authenticator object
if *httpAuthFile!="" { if *httpAuthFile!="" {
secrets := auth.HtpasswdFileProvider(*httpAuthFile) secrets := auth.HtpasswdFileProvider(*httpAuthFile)

View File

@ -81,42 +81,28 @@ func dockerHandler(containerManager manager.Manager) auth.AuthenticatedHandlerFu
} }
} }
// Register http handlers for pages. // Register http handlers
func RegisterHandlersDigest(containerManager manager.Manager,authenticator *auth.DigestAuth) error { func RegisterHandlersDigest(containerManager manager.Manager,authenticator *auth.DigestAuth) error {
// Register the handler for the containers page. // Register the handler for the containers page.
if authenticator!=nil { if authenticator!=nil {
http.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager))) http.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
http.HandleFunc(DockerPage, authenticator.Wrap(dockerHandler(containerManager)))
} else { } else {
http.HandleFunc(ContainersPage, containerHandlerNoAuth(containerManager)) http.HandleFunc(ContainersPage, containerHandlerNoAuth(containerManager))
http.HandleFunc(DockerPage, dockerHandlerNoAuth(containerManager))
} }
// Register the handler for the docker page.
if authenticator!=nil {
http.HandleFunc(DockerPage, authenticator.Wrap(dockerHandler(containerManager)))
} else {
http.HandleFunc(ContainersPage, dockerHandlerNoAuth(containerManager))
}
return nil return nil
} }
func RegisterHandlersBasic(containerManager manager.Manager,authenticator *auth.BasicAuth) error { func RegisterHandlersBasic(containerManager manager.Manager,authenticator *auth.BasicAuth) error {
// Register the handler for the containers and docker age.
// Register the handler for the containers page.
if authenticator!=nil { if authenticator!=nil {
http.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager))) http.HandleFunc(ContainersPage, authenticator.Wrap(containerHandler(containerManager)))
} else {
http.HandleFunc(ContainersPage, containerHandlerNoAuth(containerManager))
}
// Register the handler for the docker page.
if authenticator!=nil {
http.HandleFunc(DockerPage, authenticator.Wrap(dockerHandler(containerManager))) http.HandleFunc(DockerPage, authenticator.Wrap(dockerHandler(containerManager)))
} else { } else {
http.HandleFunc(ContainersPage, containerHandlerNoAuth(containerManager))
http.HandleFunc(DockerPage, dockerHandlerNoAuth(containerManager)) http.HandleFunc(DockerPage, dockerHandlerNoAuth(containerManager))
} }
return nil return nil
} }