diff --git a/api/server/router/system/system_routes.go b/api/server/router/system/system_routes.go index 5e508610d7..89ff1a79b4 100644 --- a/api/server/router/system/system_routes.go +++ b/api/server/router/system/system_routes.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/events" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/registry" timetypes "github.com/docker/docker/api/types/time" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/pkg/ioutils" @@ -154,7 +155,7 @@ func (s *systemRouter) postAuth(ctx context.Context, w http.ResponseWriter, r *h if err != nil { return err } - return httputils.WriteJSON(w, http.StatusOK, &types.AuthResponse{ + return httputils.WriteJSON(w, http.StatusOK, ®istry.AuthenticateOKBody{ Status: status, IdentityToken: token, }) diff --git a/api/swagger.yaml b/api/swagger.yaml index 64ad015d41..79cde950a5 100644 --- a/api/swagger.yaml +++ b/api/swagger.yaml @@ -4612,23 +4612,24 @@ paths: post: summary: "Check auth configuration" description: "Validate credentials for a registry and, if available, get an identity token for accessing the registry without password." - operationId: "checkAuthentication" - consumes: - - "application/json" - produces: - - "application/json" + operationId: "Authenticate" + consumes: ["application/json"] + produces: ["application/json"] responses: 200: - description: "No error" + description: "An identity token was generated successfully." schema: type: "object" + required: [Status] properties: Status: description: "The status of the authentication" type: "string" + x-nullable: false IdentityToken: description: "An opaque token used to authenticate a user after a successful login" type: "string" + x-nullable: false examples: application/json: Status: "Login Succeeded" @@ -4645,8 +4646,7 @@ paths: description: "Authentication to check" schema: $ref: "#/definitions/AuthConfig" - tags: - - "Misc" + tags: ["Registry"] /info: get: summary: "Get system information" diff --git a/api/types/registry/authenticate.go b/api/types/registry/authenticate.go new file mode 100644 index 0000000000..5e37d19bd4 --- /dev/null +++ b/api/types/registry/authenticate.go @@ -0,0 +1,21 @@ +package registry + +// ---------------------------------------------------------------------------- +// DO NOT EDIT THIS FILE +// This file was generated by `swagger generate operation` +// +// See hack/swagger-gen.sh +// ---------------------------------------------------------------------------- + +// AuthenticateOKBody authenticate o k body +// swagger:model AuthenticateOKBody +type AuthenticateOKBody struct { + + // An opaque token used to authenticate a user after a successful login + // Required: true + IdentityToken string `json:"IdentityToken"` + + // The status of the authentication + // Required: true + Status string `json:"Status"` +} diff --git a/api/types/types.go b/api/types/types.go index fd58d4d856..6f5f753c8b 100644 --- a/api/types/types.go +++ b/api/types/types.go @@ -13,17 +13,6 @@ import ( "github.com/docker/go-connections/nat" ) -// AuthResponse contains response of Remote API: -// POST "/auth" -type AuthResponse struct { - // Status is the authentication status - Status string `json:"Status"` - - // IdentityToken is an opaque token used for authenticating - // a user after a successful login. - IdentityToken string `json:"IdentityToken,omitempty"` -} - // ContainerWaitResponse contains response of Remote API: // POST "/containers/"+containerID+"/wait" type ContainerWaitResponse struct { diff --git a/client/interface.go b/client/interface.go index b303d2fde8..f044c32352 100644 --- a/client/interface.go +++ b/client/interface.go @@ -127,7 +127,7 @@ type SwarmAPIClient interface { type SystemAPIClient interface { Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Info(ctx context.Context) (types.Info, error) - RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) + RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) DiskUsage(ctx context.Context) (types.DiskUsage, error) Ping(ctx context.Context) (bool, error) } diff --git a/client/login.go b/client/login.go index d8d277ccba..600dc7196f 100644 --- a/client/login.go +++ b/client/login.go @@ -6,22 +6,23 @@ import ( "net/url" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "golang.org/x/net/context" ) // RegistryLogin authenticates the docker server with a given docker registry. // It returns UnauthorizerError when the authentication fails. -func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (types.AuthResponse, error) { +func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) if resp.statusCode == http.StatusUnauthorized { - return types.AuthResponse{}, unauthorizedError{err} + return registry.AuthenticateOKBody{}, unauthorizedError{err} } if err != nil { - return types.AuthResponse{}, err + return registry.AuthenticateOKBody{}, err } - var response types.AuthResponse + var response registry.AuthenticateOKBody err = json.NewDecoder(resp.body).Decode(&response) ensureReaderClosed(resp) return response, err diff --git a/hack/generate-swagger-api.sh b/hack/generate-swagger-api.sh index 43e8da75e9..2a7c8f2053 100755 --- a/hack/generate-swagger-api.sh +++ b/hack/generate-swagger-api.sh @@ -16,4 +16,5 @@ swagger generate operation -f api/swagger.yaml \ -n VolumesList \ -n VolumesCreate \ -n ContainerCreate \ - -n ContainerUpdate + -n ContainerUpdate \ + -n Authenticate