1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/api/server/router/local/auth.go
Morgan Bauer 215bfc73d2
refactor away direct references to daemon member
- add daemon methods Authenticate & SearchRegistryForImages
 - use new methods instead of directly accessing RegistryService

Signed-off-by: Morgan Bauer <mbauer@us.ibm.com>
2015-10-09 14:40:03 -07:00

27 lines
640 B
Go

package local
import (
"encoding/json"
"net/http"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/cliconfig"
"golang.org/x/net/context"
)
func (s *router) postAuth(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
var config *cliconfig.AuthConfig
err := json.NewDecoder(r.Body).Decode(&config)
r.Body.Close()
if err != nil {
return err
}
status, err := s.daemon.AuthenticateToRegistry(config)
if err != nil {
return err
}
return httputils.WriteJSON(w, http.StatusOK, &types.AuthResponse{
Status: status,
})
}