From 9fca47ba1d11d1e52844cde84884436a07f809d9 Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Fri, 13 Jul 2018 18:23:13 -0700 Subject: [PATCH 1/4] create User Api --- Gopkg.lock | 6 +- cmd/argocd/commands/root.go | 1 + cmd/argocd/commands/users.go | 71 ++ pkg/apiclient/apiclient.go | 20 + pkg/apis/application/v1alpha1/generated.proto | 4 +- server/server.go | 4 +- server/swagger.json | 65 +- server/users/users.go | 52 ++ server/users/users.pb.go | 712 ++++++++++++++++++ server/users/users.pb.gw.go | 138 ++++ server/users/users.proto | 37 + util/settings/settings.go | 8 +- 12 files changed, 1101 insertions(+), 17 deletions(-) create mode 100644 cmd/argocd/commands/users.go create mode 100644 server/users/users.go create mode 100644 server/users/users.pb.go create mode 100644 server/users/users.pb.gw.go create mode 100644 server/users/users.proto diff --git a/Gopkg.lock b/Gopkg.lock index 3a27612d46ed1..9bdb0a9430ca9 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1022,8 +1022,12 @@ [[projects]] name = "k8s.io/kubernetes" packages = [ + "pkg/apis/apps", + "pkg/apis/autoscaling", "pkg/apis/batch", "pkg/apis/core", + "pkg/apis/extensions", + "pkg/apis/networking", "pkg/kubectl/scheme" ] revision = "81753b10df112992bf51bbc2c2f85208aad78335" @@ -1032,6 +1036,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "839d26383e983bd1388439f67b8ba360e3479b14c4a731f48413fa6ed78f6485" + inputs-digest = "2eaad7537e4d4bc23be336a9e96c3e589cefccf6913125a37bf9b069bf02b5e9" solver-name = "gps-cdcl" solver-version = 1 diff --git a/cmd/argocd/commands/root.go b/cmd/argocd/commands/root.go index 407232d1a6cae..234517d7f2e8d 100644 --- a/cmd/argocd/commands/root.go +++ b/cmd/argocd/commands/root.go @@ -30,6 +30,7 @@ func NewCommand() *cobra.Command { command.AddCommand(NewRepoCommand(&clientOpts)) command.AddCommand(NewContextCommand(&clientOpts)) command.AddCommand(NewProjectCommand(&clientOpts)) + command.AddCommand(NewUsersCommand(&clientOpts)) defaultLocalConfigPath, err := localconfig.DefaultLocalConfigPath() errors.CheckError(err) diff --git a/cmd/argocd/commands/users.go b/cmd/argocd/commands/users.go new file mode 100644 index 0000000000000..baa7fc0e95cdb --- /dev/null +++ b/cmd/argocd/commands/users.go @@ -0,0 +1,71 @@ +package commands + +import ( + "context" + "fmt" + "os" + + "github.com/argoproj/argo-cd/errors" + argocdclient "github.com/argoproj/argo-cd/pkg/apiclient" + "github.com/argoproj/argo-cd/server/users" + "github.com/argoproj/argo-cd/util" + "github.com/argoproj/argo-cd/util/settings" + "github.com/spf13/cobra" +) + +func NewUsersCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { + var command = &cobra.Command{ + Use: "users", + Short: "Manage users", + Run: func(c *cobra.Command, args []string) { + c.HelpFunc()(c, args) + os.Exit(1) + }, + } + command.AddCommand(NewUsersChangePasswordCommand(clientOpts)) + return command +} + +func NewUsersChangePasswordCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { + var ( + CurrentPassword string + NewPassword string + ) + var command = &cobra.Command{ + Use: "change-password USERNAME", + Short: "Change User Password", + Run: func(c *cobra.Command, args []string) { + if len(args) == 0 { + c.HelpFunc()(c, args) + os.Exit(1) + } + + if CurrentPassword == "" { + CurrentPassword = settings.ReadAndConfirmPassword("Current Password") + } + if NewPassword == "" { + NewPassword = settings.ReadAndConfirmPassword("New Password") + } + + userName := args[0] + body := users.Body{ + CurrentPassword: CurrentPassword, + NewPassword: NewPassword, + } + userPasswordRequest := users.UsersPasswordRequest{ + Name: userName, + Body: &body, + } + + conn, usrIf := argocdclient.NewClientOrDie(clientOpts).NewUsersClientOrDie() + defer util.Close(conn) + _, err := usrIf.UpdatePassword(context.Background(), &userPasswordRequest) + errors.CheckError(err) + fmt.Printf("password for user %s updated to %s \n", userName, NewPassword) + }, + } + + command.Flags().StringVar(&CurrentPassword, "current-password", "", "current password you wish to change") + command.Flags().StringVar(&NewPassword, "new-password", "", "new password you want to update to") + return command +} diff --git a/pkg/apiclient/apiclient.go b/pkg/apiclient/apiclient.go index f320ff1769409..54cfa9574cadc 100644 --- a/pkg/apiclient/apiclient.go +++ b/pkg/apiclient/apiclient.go @@ -17,6 +17,7 @@ import ( "github.com/argoproj/argo-cd/server/repository" "github.com/argoproj/argo-cd/server/session" "github.com/argoproj/argo-cd/server/settings" + "github.com/argoproj/argo-cd/server/users" "github.com/argoproj/argo-cd/server/version" grpc_util "github.com/argoproj/argo-cd/util/grpc" "github.com/argoproj/argo-cd/util/localconfig" @@ -51,6 +52,8 @@ type Client interface { NewVersionClientOrDie() (*grpc.ClientConn, version.VersionServiceClient) NewProjectClient() (*grpc.ClientConn, project.ProjectServiceClient, error) NewProjectClientOrDie() (*grpc.ClientConn, project.ProjectServiceClient) + NewUsersClient() (*grpc.ClientConn, users.UsersServiceClient, error) + NewUsersClientOrDie() (*grpc.ClientConn, users.UsersServiceClient) } // ClientOptions hold address, security, and other settings for the API client. @@ -312,3 +315,20 @@ func (c *client) NewProjectClientOrDie() (*grpc.ClientConn, project.ProjectServi } return conn, projIf } + +func (c *client) NewUsersClient() (*grpc.ClientConn, users.UsersServiceClient, error) { + conn, err := c.NewConn() + if err != nil { + return nil, nil, err + } + usrIf := users.NewUsersServiceClient(conn) + return conn, usrIf, nil +} + +func (c *client) NewUsersClientOrDie() (*grpc.ClientConn, users.UsersServiceClient) { + conn, usrIf, err := c.NewUsersClient() + if err != nil { + log.Fatalf("Failed to establish connection to %s: %v", c.ServerAddr, err) + } + return conn, usrIf +} diff --git a/pkg/apis/application/v1alpha1/generated.proto b/pkg/apis/application/v1alpha1/generated.proto index 0a7d6c7c0b80d..717307dbb07c3 100644 --- a/pkg/apis/application/v1alpha1/generated.proto +++ b/pkg/apis/application/v1alpha1/generated.proto @@ -233,10 +233,10 @@ message HookStatus { // Name is the resource name optional string name = 1; - // Name is the resource name + // Kind is the resource kind optional string kind = 2; - // Name is the resource name + // APIVersion is the resource API version optional string apiVersion = 3; // Type is the type of hook (e.g. PreSync, Sync, PostSync, Skip) diff --git a/server/server.go b/server/server.go index 4005f4d9bbd60..1a00305462eb0 100644 --- a/server/server.go +++ b/server/server.go @@ -41,6 +41,7 @@ import ( "github.com/argoproj/argo-cd/server/repository" "github.com/argoproj/argo-cd/server/session" "github.com/argoproj/argo-cd/server/settings" + "github.com/argoproj/argo-cd/server/users" "github.com/argoproj/argo-cd/server/version" "github.com/argoproj/argo-cd/util" "github.com/argoproj/argo-cd/util/db" @@ -323,6 +324,7 @@ func (a *ArgoCDServer) newGRPCServer() *grpc.Server { applicationService := application.NewServer(a.Namespace, a.KubeClientset, a.AppClientset, a.RepoClientset, db, a.enf, projectLock) projectService := project.NewServer(a.Namespace, a.AppClientset, a.enf, projectLock) settingsService := settings.NewServer(a.settingsMgr) + usersService := users.NewServer(a.sessionMgr, a.settingsMgr) version.RegisterVersionServiceServer(grpcS, &version.Server{}) cluster.RegisterClusterServiceServer(grpcS, clusterService) application.RegisterApplicationServiceServer(grpcS, applicationService) @@ -330,7 +332,7 @@ func (a *ArgoCDServer) newGRPCServer() *grpc.Server { session.RegisterSessionServiceServer(grpcS, sessionService) settings.RegisterSettingsServiceServer(grpcS, settingsService) project.RegisterProjectServiceServer(grpcS, projectService) - + users.RegisterUsersServiceServer(grpcS, usersService) // Register reflection service on gRPC server. reflection.Register(grpcS) return grpcS diff --git a/server/swagger.json b/server/swagger.json index d90bb7e3a56a4..52d3dcd5dc38c 100644 --- a/server/swagger.json +++ b/server/swagger.json @@ -22,7 +22,7 @@ "ApplicationService" ], "summary": "List returns list of applications", - "operationId": "ListMixin5", + "operationId": "ListMixin6", "parameters": [ { "type": "string", @@ -58,7 +58,7 @@ "ApplicationService" ], "summary": "Create creates an application", - "operationId": "CreateMixin5", + "operationId": "CreateMixin6", "parameters": [ { "name": "body", @@ -85,7 +85,7 @@ "ApplicationService" ], "summary": "Update updates an application", - "operationId": "UpdateMixin5", + "operationId": "UpdateMixin6", "parameters": [ { "type": "string", @@ -118,7 +118,7 @@ "ApplicationService" ], "summary": "Get returns an application by name", - "operationId": "GetMixin5", + "operationId": "GetMixin6", "parameters": [ { "type": "string", @@ -155,7 +155,7 @@ "ApplicationService" ], "summary": "Delete deletes an application", - "operationId": "DeleteMixin5", + "operationId": "DeleteMixin6", "parameters": [ { "type": "string", @@ -865,7 +865,7 @@ "SessionService" ], "summary": "Create a new JWT for authentication and set a cookie if using HTTP.", - "operationId": "CreateMixin6", + "operationId": "CreateMixin7", "parameters": [ { "name": "body", @@ -890,7 +890,7 @@ "SessionService" ], "summary": "Delete an existing JWT cookie if using HTTP.", - "operationId": "DeleteMixin6", + "operationId": "DeleteMixin7", "responses": { "200": { "description": "(empty)", @@ -956,6 +956,39 @@ } } }, + "/api/v1/users/{name}/password": { + "put": { + "tags": [ + "UsersService" + ], + "summary": "Update updates an application", + "operationId": "UpdatePassword", + "parameters": [ + { + "type": "string", + "name": "name", + "in": "path", + "required": true + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/usersBody" + } + } + ], + "responses": { + "200": { + "description": "(empty)", + "schema": { + "$ref": "#/definitions/usersUserResponse" + } + } + } + } + }, "/api/version": { "get": { "tags": [ @@ -1285,6 +1318,20 @@ } } }, + "usersBody": { + "type": "object", + "properties": { + "currentPassword": { + "type": "string" + }, + "newPassword": { + "type": "string" + } + } + }, + "usersUserResponse": { + "type": "object" + }, "v1Event": { "description": "Event is a report of an event somewhere in the cluster.", "type": "object", @@ -1968,11 +2015,11 @@ "properties": { "apiVersion": { "type": "string", - "title": "Name is the resource name" + "title": "APIVersion is the resource API version" }, "kind": { "type": "string", - "title": "Name is the resource name" + "title": "Kind is the resource kind" }, "message": { "description": "A human readable message indicating details about why the resource is in this condition.", diff --git a/server/users/users.go b/server/users/users.go new file mode 100644 index 0000000000000..b46cbb7a5a995 --- /dev/null +++ b/server/users/users.go @@ -0,0 +1,52 @@ +package users + +import ( + "github.com/argoproj/argo-cd/util/password" + "github.com/argoproj/argo-cd/util/session" + "github.com/argoproj/argo-cd/util/settings" + "golang.org/x/net/context" +) + +// Server provides a Session service +type Server struct { + sessionMgr *session.SessionManager + settingsMgr *settings.SettingsManager +} + +// NewServer returns a new instance of the Session service +func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.SettingsManager) *Server { + return &Server{ + sessionMgr: sessionMgr, + settingsMgr: settingsMgr, + } + +} + +//This Function is used to Update User Passwords \ +func (s *Server) UpdatePassword(ctx context.Context, q *UsersPasswordRequest) (*UserResponse, error) { + + cdSettings, err := s.settingsMgr.GetSettings() + if err != nil { + return nil, err + } + + err = s.sessionMgr.VerifyUsernamePassword(q.Name, q.Body.GetCurrentPassword()) + if err != nil { + return nil, err + } + + hashedPassword, err := password.HashPassword(q.Body.GetNewPassword()) + if err != nil { + return nil, err + } + + cdSettings.LocalUsers[q.Name] = hashedPassword + + err = s.settingsMgr.SaveSettings(cdSettings) + if err != nil { + return nil, err + } + + return nil, nil + +} diff --git a/server/users/users.pb.go b/server/users/users.pb.go new file mode 100644 index 0000000000000..3b80180258f45 --- /dev/null +++ b/server/users/users.pb.go @@ -0,0 +1,712 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: server/users/users.proto + +/* + Package users is a generated protocol buffer package. + + It is generated from these files: + server/users/users.proto + + It has these top-level messages: + Body + UsersPasswordRequest + UserResponse +*/ +package users + +import proto "github.com/gogo/protobuf/proto" +import fmt "fmt" +import math "math" +import _ "github.com/gogo/protobuf/gogoproto" +import _ "google.golang.org/genproto/googleapis/api/annotations" + +import context "golang.org/x/net/context" +import grpc "google.golang.org/grpc" + +import io "io" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package + +type Body struct { + CurrentPassword string `protobuf:"bytes,2,opt,name=currentPassword,proto3" json:"currentPassword,omitempty"` + NewPassword string `protobuf:"bytes,3,opt,name=newPassword,proto3" json:"newPassword,omitempty"` +} + +func (m *Body) Reset() { *m = Body{} } +func (m *Body) String() string { return proto.CompactTextString(m) } +func (*Body) ProtoMessage() {} +func (*Body) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{0} } + +func (m *Body) GetCurrentPassword() string { + if m != nil { + return m.CurrentPassword + } + return "" +} + +func (m *Body) GetNewPassword() string { + if m != nil { + return m.NewPassword + } + return "" +} + +type UsersPasswordRequest struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Body *Body `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"` +} + +func (m *UsersPasswordRequest) Reset() { *m = UsersPasswordRequest{} } +func (m *UsersPasswordRequest) String() string { return proto.CompactTextString(m) } +func (*UsersPasswordRequest) ProtoMessage() {} +func (*UsersPasswordRequest) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{1} } + +func (m *UsersPasswordRequest) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *UsersPasswordRequest) GetBody() *Body { + if m != nil { + return m.Body + } + return nil +} + +type UserResponse struct { +} + +func (m *UserResponse) Reset() { *m = UserResponse{} } +func (m *UserResponse) String() string { return proto.CompactTextString(m) } +func (*UserResponse) ProtoMessage() {} +func (*UserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{2} } + +func init() { + proto.RegisterType((*Body)(nil), "users.Body") + proto.RegisterType((*UsersPasswordRequest)(nil), "users.UsersPasswordRequest") + proto.RegisterType((*UserResponse)(nil), "users.UserResponse") +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// Client API for UsersService service + +type UsersServiceClient interface { + // Update updates an application + UpdatePassword(ctx context.Context, in *UsersPasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) +} + +type usersServiceClient struct { + cc *grpc.ClientConn +} + +func NewUsersServiceClient(cc *grpc.ClientConn) UsersServiceClient { + return &usersServiceClient{cc} +} + +func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UsersPasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) { + out := new(UserResponse) + err := grpc.Invoke(ctx, "/users.UsersService/UpdatePassword", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for UsersService service + +type UsersServiceServer interface { + // Update updates an application + UpdatePassword(context.Context, *UsersPasswordRequest) (*UserResponse, error) +} + +func RegisterUsersServiceServer(s *grpc.Server, srv UsersServiceServer) { + s.RegisterService(&_UsersService_serviceDesc, srv) +} + +func _UsersService_UpdatePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UsersPasswordRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(UsersServiceServer).UpdatePassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/users.UsersService/UpdatePassword", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(UsersServiceServer).UpdatePassword(ctx, req.(*UsersPasswordRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _UsersService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "users.UsersService", + HandlerType: (*UsersServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "UpdatePassword", + Handler: _UsersService_UpdatePassword_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "server/users/users.proto", +} + +func (m *Body) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Body) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.CurrentPassword) > 0 { + dAtA[i] = 0x12 + i++ + i = encodeVarintUsers(dAtA, i, uint64(len(m.CurrentPassword))) + i += copy(dAtA[i:], m.CurrentPassword) + } + if len(m.NewPassword) > 0 { + dAtA[i] = 0x1a + i++ + i = encodeVarintUsers(dAtA, i, uint64(len(m.NewPassword))) + i += copy(dAtA[i:], m.NewPassword) + } + return i, nil +} + +func (m *UsersPasswordRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UsersPasswordRequest) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if len(m.Name) > 0 { + dAtA[i] = 0xa + i++ + i = encodeVarintUsers(dAtA, i, uint64(len(m.Name))) + i += copy(dAtA[i:], m.Name) + } + if m.Body != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintUsers(dAtA, i, uint64(m.Body.Size())) + n1, err := m.Body.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n1 + } + return i, nil +} + +func (m *UserResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UserResponse) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + return i, nil +} + +func encodeVarintUsers(dAtA []byte, offset int, v uint64) int { + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return offset + 1 +} +func (m *Body) Size() (n int) { + var l int + _ = l + l = len(m.CurrentPassword) + if l > 0 { + n += 1 + l + sovUsers(uint64(l)) + } + l = len(m.NewPassword) + if l > 0 { + n += 1 + l + sovUsers(uint64(l)) + } + return n +} + +func (m *UsersPasswordRequest) Size() (n int) { + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovUsers(uint64(l)) + } + if m.Body != nil { + l = m.Body.Size() + n += 1 + l + sovUsers(uint64(l)) + } + return n +} + +func (m *UserResponse) Size() (n int) { + var l int + _ = l + return n +} + +func sovUsers(x uint64) (n int) { + for { + n++ + x >>= 7 + if x == 0 { + break + } + } + return n +} +func sozUsers(x uint64) (n int) { + return sovUsers(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Body) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Body: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Body: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentPassword", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthUsers + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CurrentPassword = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewPassword", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthUsers + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.NewPassword = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipUsers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthUsers + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UsersPasswordRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UsersPasswordRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UsersPasswordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthUsers + } + postIndex := iNdEx + intStringLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Body", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthUsers + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Body == nil { + m.Body = &Body{} + } + if err := m.Body.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipUsers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthUsers + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UserResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUsers + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UserResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UserResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipUsers(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthUsers + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipUsers(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowUsers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowUsers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + return iNdEx, nil + case 1: + iNdEx += 8 + return iNdEx, nil + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowUsers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + iNdEx += length + if length < 0 { + return 0, ErrInvalidLengthUsers + } + return iNdEx, nil + case 3: + for { + var innerWire uint64 + var start int = iNdEx + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowUsers + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + innerWire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + innerWireType := int(innerWire & 0x7) + if innerWireType == 4 { + break + } + next, err := skipUsers(dAtA[start:]) + if err != nil { + return 0, err + } + iNdEx = start + next + } + return iNdEx, nil + case 4: + return iNdEx, nil + case 5: + iNdEx += 4 + return iNdEx, nil + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + } + panic("unreachable") +} + +var ( + ErrInvalidLengthUsers = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowUsers = fmt.Errorf("proto: integer overflow") +) + +func init() { proto.RegisterFile("server/users/users.proto", fileDescriptorUsers) } + +var fileDescriptorUsers = []byte{ + // 312 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x41, 0x4b, 0xf3, 0x40, + 0x10, 0x25, 0xfd, 0xfa, 0x09, 0x6e, 0xa5, 0xc2, 0xda, 0x43, 0x89, 0x5a, 0x4b, 0x40, 0x28, 0x88, + 0x59, 0xac, 0xe0, 0xc1, 0x63, 0xaf, 0x5e, 0x24, 0xd2, 0x8b, 0xb7, 0x4d, 0x32, 0xc4, 0x88, 0xdd, + 0x89, 0xbb, 0x9b, 0x94, 0x22, 0x22, 0xf8, 0x17, 0xfc, 0x53, 0x1e, 0x05, 0xff, 0x80, 0x04, 0x7f, + 0x88, 0x64, 0x92, 0x96, 0x20, 0x5e, 0x96, 0x99, 0xf7, 0x66, 0xde, 0xbe, 0x7d, 0xcb, 0x86, 0x06, + 0x74, 0x01, 0x5a, 0xe4, 0x06, 0xb4, 0xa9, 0x4f, 0x3f, 0xd3, 0x68, 0x91, 0xff, 0xa7, 0xc6, 0x1d, + 0x24, 0x98, 0x20, 0x21, 0xa2, 0xaa, 0x6a, 0xd2, 0x3d, 0x48, 0x10, 0x93, 0x07, 0x10, 0x32, 0x4b, + 0x85, 0x54, 0x0a, 0xad, 0xb4, 0x29, 0xaa, 0x66, 0xd5, 0x0b, 0x58, 0x77, 0x86, 0xf1, 0x8a, 0x4f, + 0xd8, 0x6e, 0x94, 0x6b, 0x0d, 0xca, 0x5e, 0x4b, 0x63, 0x96, 0xa8, 0xe3, 0x61, 0x67, 0xec, 0x4c, + 0xb6, 0x83, 0xdf, 0x30, 0x1f, 0xb3, 0x9e, 0x82, 0xe5, 0x66, 0xea, 0x1f, 0x4d, 0xb5, 0x21, 0xef, + 0x8a, 0x0d, 0xe6, 0x95, 0xa1, 0x35, 0x10, 0xc0, 0x63, 0x0e, 0xc6, 0x72, 0xce, 0xba, 0x4a, 0x2e, + 0x60, 0xe8, 0xd0, 0x0a, 0xd5, 0xfc, 0x88, 0x75, 0x43, 0x8c, 0x57, 0x74, 0x59, 0x6f, 0xda, 0xf3, + 0xeb, 0x67, 0x55, 0x96, 0x02, 0x22, 0xbc, 0x3e, 0xdb, 0xa9, 0xc4, 0x02, 0x30, 0x19, 0x2a, 0x03, + 0xd3, 0x97, 0xba, 0x37, 0x37, 0xa0, 0x8b, 0x34, 0x02, 0x8e, 0xac, 0x3f, 0xcf, 0x62, 0x69, 0x61, + 0x63, 0x70, 0xbf, 0x11, 0xf9, 0xcb, 0x83, 0xbb, 0xd7, 0x22, 0xd7, 0x9a, 0xde, 0xc9, 0xeb, 0xe7, + 0xf7, 0x5b, 0xe7, 0xd8, 0x3d, 0xa4, 0x90, 0x8a, 0xb3, 0x26, 0xe2, 0xa7, 0xca, 0xe1, 0xb3, 0xc8, + 0x1a, 0x89, 0x4b, 0x32, 0x34, 0xbb, 0x78, 0x2f, 0x47, 0xce, 0x47, 0x39, 0x72, 0xbe, 0xca, 0x91, + 0x73, 0x3b, 0x49, 0x52, 0x7b, 0x97, 0x87, 0x7e, 0x84, 0x0b, 0x21, 0x35, 0xc5, 0x7f, 0x4f, 0xc5, + 0x69, 0x14, 0x8b, 0xf6, 0x87, 0x85, 0x5b, 0x14, 0xf8, 0xf9, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x31, 0x1c, 0x63, 0xb8, 0xc7, 0x01, 0x00, 0x00, +} diff --git a/server/users/users.pb.gw.go b/server/users/users.pb.gw.go new file mode 100644 index 0000000000000..3823ed4e4f512 --- /dev/null +++ b/server/users/users.pb.gw.go @@ -0,0 +1,138 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: server/users/users.proto + +/* +Package users is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package users + +import ( + "io" + "net/http" + + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/status" +) + +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray + +func request_UsersService_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, client UsersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq UsersPasswordRequest + var metadata runtime.ServerMetadata + + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Body); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["name"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name") + } + + protoReq.Name, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err) + } + + msg, err := client.UpdatePassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +// RegisterUsersServiceHandlerFromEndpoint is same as RegisterUsersServiceHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterUsersServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Printf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterUsersServiceHandler(ctx, mux, conn) +} + +// RegisterUsersServiceHandler registers the http handlers for service UsersService to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterUsersServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterUsersServiceHandlerClient(ctx, mux, NewUsersServiceClient(conn)) +} + +// RegisterUsersServiceHandler registers the http handlers for service UsersService to "mux". +// The handlers forward requests to the grpc endpoint over the given implementation of "UsersServiceClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UsersServiceClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "UsersServiceClient" to call the correct interceptors. +func RegisterUsersServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UsersServiceClient) error { + + mux.Handle("PUT", pattern_UsersService_UpdatePassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + if cn, ok := w.(http.CloseNotifier); ok { + go func(done <-chan struct{}, closed <-chan bool) { + select { + case <-done: + case <-closed: + cancel() + } + }(ctx.Done(), cn.CloseNotify()) + } + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_UsersService_UpdatePassword_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_UsersService_UpdatePassword_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_UsersService_UpdatePassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"api", "v1", "users", "name", "password"}, "")) +) + +var ( + forward_UsersService_UpdatePassword_0 = runtime.ForwardResponseMessage +) diff --git a/server/users/users.proto b/server/users/users.proto new file mode 100644 index 0000000000000..7e64e5bb72aa5 --- /dev/null +++ b/server/users/users.proto @@ -0,0 +1,37 @@ +syntax = "proto3"; +option go_package = "github.com/argoproj/argo-cd/server/users"; + +//Users Service +// +// +//Users Service API updates ArgoCD users settings + +package users; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; + + +message Body { + string currentPassword = 2; + string newPassword = 3; +} +message UsersPasswordRequest { + string name = 1; + Body body = 2; +} + +message UserResponse {} + +service UsersService { + + + // Update updates an application + rpc UpdatePassword(UsersPasswordRequest) returns (UserResponse) { + option (google.api.http) = { + put: "/api/v1/users/{name}/password" + body: "body" + }; + } + +} diff --git a/util/settings/settings.go b/util/settings/settings.go index 724a3f38c4559..69292978e7cb9 100644 --- a/util/settings/settings.go +++ b/util/settings/settings.go @@ -388,13 +388,13 @@ func (mgr *SettingsManager) notifySubscribers() { } } -func readAndConfirmPassword() string { +func ReadAndConfirmPassword(types string) string { for { - fmt.Print("*** Enter an admin password: ") + fmt.Printf("*** Enter an %s password: ", types) password, err := terminal.ReadPassword(syscall.Stdin) errors.CheckError(err) fmt.Print("\n") - fmt.Print("*** Confirm the admin password: ") + fmt.Printf("*** Confirm the %s password: ", types) confirmPassword, err := terminal.ReadPassword(syscall.Stdin) errors.CheckError(err) fmt.Print("\n") @@ -426,7 +426,7 @@ func UpdateSettings(defaultPassword string, settingsMgr *SettingsManager, update if _, ok := cdSettings.LocalUsers[common.ArgoCDAdminUsername]; !ok || updateSuperuser { passwordRaw := defaultPassword if passwordRaw == "" { - passwordRaw = readAndConfirmPassword() + passwordRaw = ReadAndConfirmPassword("admin") } log.Infof("password set to %s", passwordRaw) hashedPassword, err := password.HashPassword(passwordRaw) From 32ad444a445b9a22dc272a80080002bce8549468 Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Sat, 14 Jul 2018 08:09:11 -0700 Subject: [PATCH 2/4] update UsersPasswordRequest to UpdatePasswordRequest --- cmd/argocd/commands/users.go | 4 +- server/users/users.go | 2 +- server/users/users.pb.go | 78 ++++++++++++++++++------------------ server/users/users.pb.gw.go | 2 +- server/users/users.proto | 4 +- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cmd/argocd/commands/users.go b/cmd/argocd/commands/users.go index baa7fc0e95cdb..6458a8035bd13 100644 --- a/cmd/argocd/commands/users.go +++ b/cmd/argocd/commands/users.go @@ -52,14 +52,14 @@ func NewUsersChangePasswordCommand(clientOpts *argocdclient.ClientOptions) *cobr CurrentPassword: CurrentPassword, NewPassword: NewPassword, } - userPasswordRequest := users.UsersPasswordRequest{ + UpdatePasswordRequest := users.UpdatePasswordRequest{ Name: userName, Body: &body, } conn, usrIf := argocdclient.NewClientOrDie(clientOpts).NewUsersClientOrDie() defer util.Close(conn) - _, err := usrIf.UpdatePassword(context.Background(), &userPasswordRequest) + _, err := usrIf.UpdatePassword(context.Background(), &UpdatePasswordRequest) errors.CheckError(err) fmt.Printf("password for user %s updated to %s \n", userName, NewPassword) }, diff --git a/server/users/users.go b/server/users/users.go index b46cbb7a5a995..3de4cac81f63e 100644 --- a/server/users/users.go +++ b/server/users/users.go @@ -23,7 +23,7 @@ func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.Setting } //This Function is used to Update User Passwords \ -func (s *Server) UpdatePassword(ctx context.Context, q *UsersPasswordRequest) (*UserResponse, error) { +func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UserResponse, error) { cdSettings, err := s.settingsMgr.GetSettings() if err != nil { diff --git a/server/users/users.pb.go b/server/users/users.pb.go index 3b80180258f45..fa0be6651ae8d 100644 --- a/server/users/users.pb.go +++ b/server/users/users.pb.go @@ -9,7 +9,7 @@ It has these top-level messages: Body - UsersPasswordRequest + UpdatePasswordRequest UserResponse */ package users @@ -60,24 +60,24 @@ func (m *Body) GetNewPassword() string { return "" } -type UsersPasswordRequest struct { +type UpdatePasswordRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Body *Body `protobuf:"bytes,2,opt,name=body" json:"body,omitempty"` } -func (m *UsersPasswordRequest) Reset() { *m = UsersPasswordRequest{} } -func (m *UsersPasswordRequest) String() string { return proto.CompactTextString(m) } -func (*UsersPasswordRequest) ProtoMessage() {} -func (*UsersPasswordRequest) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{1} } +func (m *UpdatePasswordRequest) Reset() { *m = UpdatePasswordRequest{} } +func (m *UpdatePasswordRequest) String() string { return proto.CompactTextString(m) } +func (*UpdatePasswordRequest) ProtoMessage() {} +func (*UpdatePasswordRequest) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{1} } -func (m *UsersPasswordRequest) GetName() string { +func (m *UpdatePasswordRequest) GetName() string { if m != nil { return m.Name } return "" } -func (m *UsersPasswordRequest) GetBody() *Body { +func (m *UpdatePasswordRequest) GetBody() *Body { if m != nil { return m.Body } @@ -94,7 +94,7 @@ func (*UserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUsers, func init() { proto.RegisterType((*Body)(nil), "users.Body") - proto.RegisterType((*UsersPasswordRequest)(nil), "users.UsersPasswordRequest") + proto.RegisterType((*UpdatePasswordRequest)(nil), "users.UpdatePasswordRequest") proto.RegisterType((*UserResponse)(nil), "users.UserResponse") } @@ -110,7 +110,7 @@ const _ = grpc.SupportPackageIsVersion4 type UsersServiceClient interface { // Update updates an application - UpdatePassword(ctx context.Context, in *UsersPasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) + UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) } type usersServiceClient struct { @@ -121,7 +121,7 @@ func NewUsersServiceClient(cc *grpc.ClientConn) UsersServiceClient { return &usersServiceClient{cc} } -func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UsersPasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) { +func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) { out := new(UserResponse) err := grpc.Invoke(ctx, "/users.UsersService/UpdatePassword", in, out, c.cc, opts...) if err != nil { @@ -134,7 +134,7 @@ func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UsersPasswo type UsersServiceServer interface { // Update updates an application - UpdatePassword(context.Context, *UsersPasswordRequest) (*UserResponse, error) + UpdatePassword(context.Context, *UpdatePasswordRequest) (*UserResponse, error) } func RegisterUsersServiceServer(s *grpc.Server, srv UsersServiceServer) { @@ -142,7 +142,7 @@ func RegisterUsersServiceServer(s *grpc.Server, srv UsersServiceServer) { } func _UsersService_UpdatePassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(UsersPasswordRequest) + in := new(UpdatePasswordRequest) if err := dec(in); err != nil { return nil, err } @@ -154,7 +154,7 @@ func _UsersService_UpdatePassword_Handler(srv interface{}, ctx context.Context, FullMethod: "/users.UsersService/UpdatePassword", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UsersServiceServer).UpdatePassword(ctx, req.(*UsersPasswordRequest)) + return srv.(UsersServiceServer).UpdatePassword(ctx, req.(*UpdatePasswordRequest)) } return interceptor(ctx, in, info, handler) } @@ -202,7 +202,7 @@ func (m *Body) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *UsersPasswordRequest) Marshal() (dAtA []byte, err error) { +func (m *UpdatePasswordRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -212,7 +212,7 @@ func (m *UsersPasswordRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UsersPasswordRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *UpdatePasswordRequest) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -277,7 +277,7 @@ func (m *Body) Size() (n int) { return n } -func (m *UsersPasswordRequest) Size() (n int) { +func (m *UpdatePasswordRequest) Size() (n int) { var l int _ = l l = len(m.Name) @@ -418,7 +418,7 @@ func (m *Body) Unmarshal(dAtA []byte) error { } return nil } -func (m *UsersPasswordRequest) Unmarshal(dAtA []byte) error { +func (m *UpdatePasswordRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -441,10 +441,10 @@ func (m *UsersPasswordRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UsersPasswordRequest: wiretype end group for non-group") + return fmt.Errorf("proto: UpdatePasswordRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UsersPasswordRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UpdatePasswordRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -690,23 +690,23 @@ func init() { proto.RegisterFile("server/users/users.proto", fileDescriptorUsers var fileDescriptorUsers = []byte{ // 312 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x41, 0x4b, 0xf3, 0x40, - 0x10, 0x25, 0xfd, 0xfa, 0x09, 0x6e, 0xa5, 0xc2, 0xda, 0x43, 0x89, 0x5a, 0x4b, 0x40, 0x28, 0x88, - 0x59, 0xac, 0xe0, 0xc1, 0x63, 0xaf, 0x5e, 0x24, 0xd2, 0x8b, 0xb7, 0x4d, 0x32, 0xc4, 0x88, 0xdd, - 0x89, 0xbb, 0x9b, 0x94, 0x22, 0x22, 0xf8, 0x17, 0xfc, 0x53, 0x1e, 0x05, 0xff, 0x80, 0x04, 0x7f, - 0x88, 0x64, 0x92, 0x96, 0x20, 0x5e, 0x96, 0x99, 0xf7, 0x66, 0xde, 0xbe, 0x7d, 0xcb, 0x86, 0x06, - 0x74, 0x01, 0x5a, 0xe4, 0x06, 0xb4, 0xa9, 0x4f, 0x3f, 0xd3, 0x68, 0x91, 0xff, 0xa7, 0xc6, 0x1d, - 0x24, 0x98, 0x20, 0x21, 0xa2, 0xaa, 0x6a, 0xd2, 0x3d, 0x48, 0x10, 0x93, 0x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8c, 0x66, 0xa8, 0x16, 0x07, 0xbc, 0x39, 0xc5, 0x64, 0x49, 0xdb, 0x5a, 0xa3, + 0xd6, 0xb0, 0x7c, 0x57, 0xe1, 0x29, 0x22, 0x22, 0x6c, 0xf3, 0xad, 0x89, 0x03, 0x1b, 0x81, 0x33, + 0xa8, 0x1d, 0x8c, 0x9e, 0x58, 0x09, 0xb8, 0x2b, 0xb0, 0xf3, 0x2c, 0x06, 0x61, 0x78, 0xfb, 0xe7, + 0x3a, 0xd1, 0xad, 0x54, 0xfe, 0x74, 0x11, 0xec, 0xac, 0xd9, 0x9a, 0x6a, 0x78, 0xf4, 0xfc, 0xfe, + 0xf9, 0xd2, 0x38, 0x0c, 0xf6, 0x29, 0xa7, 0xf9, 0x49, 0x95, 0xf2, 0x43, 0xe1, 0xf1, 0x51, 0x9a, + 0x4a, 0xe2, 0x9c, 0x2c, 0x8d, 0xcf, 0x5e, 0x57, 0x3d, 0xf6, 0xb6, 0xea, 0xb1, 0x8f, 0x55, 0x8f, + 0x5d, 0x0f, 0xd2, 0xcc, 0xdf, 0xe4, 0xd3, 0x61, 0x8c, 0x33, 0xa9, 0x2c, 0x5d, 0xe0, 0x96, 0x8a, + 0xe3, 0x38, 0x91, 0xf5, 0x9b, 0x4d, 0x37, 0x28, 0xf3, 0xd3, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xb9, 0xe3, 0x4b, 0x6c, 0xca, 0x01, 0x00, 0x00, } diff --git a/server/users/users.pb.gw.go b/server/users/users.pb.gw.go index 3823ed4e4f512..0664d517d0c39 100644 --- a/server/users/users.pb.gw.go +++ b/server/users/users.pb.gw.go @@ -29,7 +29,7 @@ var _ = runtime.String var _ = utilities.NewDoubleArray func request_UsersService_UpdatePassword_0(ctx context.Context, marshaler runtime.Marshaler, client UsersServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq UsersPasswordRequest + var protoReq UpdatePasswordRequest var metadata runtime.ServerMetadata if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.Body); err != nil { diff --git a/server/users/users.proto b/server/users/users.proto index 7e64e5bb72aa5..351b9828c1cef 100644 --- a/server/users/users.proto +++ b/server/users/users.proto @@ -16,7 +16,7 @@ message Body { string currentPassword = 2; string newPassword = 3; } -message UsersPasswordRequest { +message UpdatePasswordRequest { string name = 1; Body body = 2; } @@ -27,7 +27,7 @@ service UsersService { // Update updates an application - rpc UpdatePassword(UsersPasswordRequest) returns (UserResponse) { + rpc UpdatePassword(UpdatePasswordRequest) returns (UserResponse) { option (google.api.http) = { put: "/api/v1/users/{name}/password" body: "body" From e06e20ecb35e4f8104107127a8955580cbec2fb1 Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Sat, 14 Jul 2018 08:10:49 -0700 Subject: [PATCH 3/4] update UserResponse to UpdatePasswordResponse --- server/swagger.json | 4 +-- server/users/users.go | 2 +- server/users/users.pb.go | 74 ++++++++++++++++++++-------------------- server/users/users.proto | 4 +-- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/server/swagger.json b/server/swagger.json index 52d3dcd5dc38c..baff5f97bd6a0 100644 --- a/server/swagger.json +++ b/server/swagger.json @@ -983,7 +983,7 @@ "200": { "description": "(empty)", "schema": { - "$ref": "#/definitions/usersUserResponse" + "$ref": "#/definitions/usersUpdatePasswordResponse" } } } @@ -1329,7 +1329,7 @@ } } }, - "usersUserResponse": { + "usersUpdatePasswordResponse": { "type": "object" }, "v1Event": { diff --git a/server/users/users.go b/server/users/users.go index 3de4cac81f63e..9faf83c29d34a 100644 --- a/server/users/users.go +++ b/server/users/users.go @@ -23,7 +23,7 @@ func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.Setting } //This Function is used to Update User Passwords \ -func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UserResponse, error) { +func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { cdSettings, err := s.settingsMgr.GetSettings() if err != nil { diff --git a/server/users/users.pb.go b/server/users/users.pb.go index fa0be6651ae8d..88cf6876f8b6c 100644 --- a/server/users/users.pb.go +++ b/server/users/users.pb.go @@ -10,7 +10,7 @@ It has these top-level messages: Body UpdatePasswordRequest - UserResponse + UpdatePasswordResponse */ package users @@ -84,18 +84,18 @@ func (m *UpdatePasswordRequest) GetBody() *Body { return nil } -type UserResponse struct { +type UpdatePasswordResponse struct { } -func (m *UserResponse) Reset() { *m = UserResponse{} } -func (m *UserResponse) String() string { return proto.CompactTextString(m) } -func (*UserResponse) ProtoMessage() {} -func (*UserResponse) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{2} } +func (m *UpdatePasswordResponse) Reset() { *m = UpdatePasswordResponse{} } +func (m *UpdatePasswordResponse) String() string { return proto.CompactTextString(m) } +func (*UpdatePasswordResponse) ProtoMessage() {} +func (*UpdatePasswordResponse) Descriptor() ([]byte, []int) { return fileDescriptorUsers, []int{2} } func init() { proto.RegisterType((*Body)(nil), "users.Body") proto.RegisterType((*UpdatePasswordRequest)(nil), "users.UpdatePasswordRequest") - proto.RegisterType((*UserResponse)(nil), "users.UserResponse") + proto.RegisterType((*UpdatePasswordResponse)(nil), "users.UpdatePasswordResponse") } // Reference imports to suppress errors if they are not otherwise used. @@ -110,7 +110,7 @@ const _ = grpc.SupportPackageIsVersion4 type UsersServiceClient interface { // Update updates an application - UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) + UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UpdatePasswordResponse, error) } type usersServiceClient struct { @@ -121,8 +121,8 @@ func NewUsersServiceClient(cc *grpc.ClientConn) UsersServiceClient { return &usersServiceClient{cc} } -func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UserResponse, error) { - out := new(UserResponse) +func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UpdatePasswordResponse, error) { + out := new(UpdatePasswordResponse) err := grpc.Invoke(ctx, "/users.UsersService/UpdatePassword", in, out, c.cc, opts...) if err != nil { return nil, err @@ -134,7 +134,7 @@ func (c *usersServiceClient) UpdatePassword(ctx context.Context, in *UpdatePassw type UsersServiceServer interface { // Update updates an application - UpdatePassword(context.Context, *UpdatePasswordRequest) (*UserResponse, error) + UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error) } func RegisterUsersServiceServer(s *grpc.Server, srv UsersServiceServer) { @@ -236,7 +236,7 @@ func (m *UpdatePasswordRequest) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *UserResponse) Marshal() (dAtA []byte, err error) { +func (m *UpdatePasswordResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -246,7 +246,7 @@ func (m *UserResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *UserResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *UpdatePasswordResponse) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -291,7 +291,7 @@ func (m *UpdatePasswordRequest) Size() (n int) { return n } -func (m *UserResponse) Size() (n int) { +func (m *UpdatePasswordResponse) Size() (n int) { var l int _ = l return n @@ -530,7 +530,7 @@ func (m *UpdatePasswordRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *UserResponse) Unmarshal(dAtA []byte) error { +func (m *UpdatePasswordResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -553,10 +553,10 @@ func (m *UserResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserResponse: wiretype end group for non-group") + return fmt.Errorf("proto: UpdatePasswordResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: UpdatePasswordResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -688,25 +688,25 @@ var ( func init() { proto.RegisterFile("server/users/users.proto", fileDescriptorUsers) } var fileDescriptorUsers = []byte{ - // 312 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x51, 0x41, 0x4b, 0xf3, 0x40, - 0x10, 0x65, 0xfb, 0xf5, 0x13, 0xdc, 0x4a, 0x85, 0x55, 0xa1, 0x84, 0x5a, 0x4b, 0x40, 0x28, 0x88, + // 313 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x51, 0x41, 0x4b, 0xf3, 0x40, + 0x10, 0x65, 0xfb, 0xf5, 0x13, 0xdc, 0x8a, 0xc2, 0xa2, 0x12, 0x42, 0x5b, 0x4b, 0x40, 0x28, 0x88, 0x5d, 0xac, 0xe0, 0xc1, 0x63, 0xcf, 0x1e, 0x24, 0xd2, 0x8b, 0xb7, 0x6d, 0x32, 0xc4, 0x88, 0xdd, - 0x59, 0x77, 0x37, 0x2d, 0x45, 0x04, 0xf1, 0x2f, 0xf8, 0xa7, 0x3c, 0x0a, 0xfe, 0x01, 0x29, 0xfe, - 0x10, 0xc9, 0x24, 0x95, 0x28, 0x5e, 0xc2, 0xe4, 0xbd, 0x99, 0x37, 0x6f, 0xdf, 0xf0, 0x8e, 0x03, - 0x3b, 0x07, 0x2b, 0x73, 0x07, 0xd6, 0x95, 0xdf, 0xa1, 0xb1, 0xe8, 0x51, 0xfc, 0xa7, 0x9f, 0x60, - 0x37, 0xc5, 0x14, 0x09, 0x91, 0x45, 0x55, 0x92, 0x41, 0x37, 0x45, 0x4c, 0xef, 0x40, 0x2a, 0x93, - 0x49, 0xa5, 0x35, 0x7a, 0xe5, 0x33, 0xd4, 0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 0x2c, 0x8d, 0x40, 0xdc, 0xf1, 0xcd, + 0x9f, 0x54, 0xd1, 0xae, 0xf5, 0x7e, 0xf5, 0xe3, 0x77, 0xfe, 0xe8, 0x56, 0xfa, 0xc1, 0xc1, 0xe3, + 0xdb, 0xc7, 0x73, 0x63, 0xdf, 0xef, 0xd0, 0xee, 0x66, 0x47, 0xf5, 0xe6, 0xef, 0x4b, 0xdf, 0x0f, + 0x32, 0xab, 0xe9, 0xa7, 0x64, 0x73, 0x74, 0xf2, 0x52, 0x74, 0xd9, 0x6b, 0xd1, 0x65, 0xef, 0x45, + 0x97, 0x5d, 0xf6, 0x93, 0xd4, 0x5d, 0xe5, 0x93, 0x41, 0x84, 0x53, 0xa9, 0x0c, 0xa5, 0x72, 0x4d, + 0xc5, 0x61, 0x14, 0xcb, 0xe5, 0x1c, 0x27, 0x6b, 0x94, 0xc3, 0xf1, 0x67, 0x00, 0x00, 0x00, 0xff, + 0xff, 0xcd, 0xc0, 0x6e, 0xa0, 0xde, 0x01, 0x00, 0x00, } diff --git a/server/users/users.proto b/server/users/users.proto index 351b9828c1cef..29a1322725004 100644 --- a/server/users/users.proto +++ b/server/users/users.proto @@ -21,13 +21,13 @@ message UpdatePasswordRequest { Body body = 2; } -message UserResponse {} +message UpdatePasswordResponse {} service UsersService { // Update updates an application - rpc UpdatePassword(UpdatePasswordRequest) returns (UserResponse) { + rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) { option (google.api.http) = { put: "/api/v1/users/{name}/password" body: "body" From 9fd22ae2b2f5b5f69014dc44f30a00cc8bc4b23d Mon Sep 17 00:00:00 2001 From: JazminGonzalez-Rivero Date: Sat, 14 Jul 2018 08:27:35 -0700 Subject: [PATCH 4/4] current password only needs to be entered once --- cmd/argocd/commands/users.go | 10 ++++++++-- server/users/users.go | 2 +- util/settings/settings.go | 8 ++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cmd/argocd/commands/users.go b/cmd/argocd/commands/users.go index 6458a8035bd13..8617c054a13b4 100644 --- a/cmd/argocd/commands/users.go +++ b/cmd/argocd/commands/users.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "os" + "syscall" "github.com/argoproj/argo-cd/errors" argocdclient "github.com/argoproj/argo-cd/pkg/apiclient" @@ -11,6 +12,7 @@ import ( "github.com/argoproj/argo-cd/util" "github.com/argoproj/argo-cd/util/settings" "github.com/spf13/cobra" + "golang.org/x/crypto/ssh/terminal" ) func NewUsersCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command { @@ -41,10 +43,14 @@ func NewUsersChangePasswordCommand(clientOpts *argocdclient.ClientOptions) *cobr } if CurrentPassword == "" { - CurrentPassword = settings.ReadAndConfirmPassword("Current Password") + fmt.Print("*** Enter your Current Password password ") + password, err := terminal.ReadPassword(syscall.Stdin) + errors.CheckError(err) + CurrentPassword = string(password) + fmt.Print("\n") } if NewPassword == "" { - NewPassword = settings.ReadAndConfirmPassword("New Password") + NewPassword = settings.ReadAndConfirmPassword() } userName := args[0] diff --git a/server/users/users.go b/server/users/users.go index 9faf83c29d34a..b3a2ac880086f 100644 --- a/server/users/users.go +++ b/server/users/users.go @@ -22,7 +22,7 @@ func NewServer(sessionMgr *session.SessionManager, settingsMgr *settings.Setting } -//This Function is used to Update User Passwords \ +//UpdatePassword is used to Update a User's Passwords func (s *Server) UpdatePassword(ctx context.Context, q *UpdatePasswordRequest) (*UpdatePasswordResponse, error) { cdSettings, err := s.settingsMgr.GetSettings() diff --git a/util/settings/settings.go b/util/settings/settings.go index 69292978e7cb9..7fd0c63596e37 100644 --- a/util/settings/settings.go +++ b/util/settings/settings.go @@ -388,13 +388,13 @@ func (mgr *SettingsManager) notifySubscribers() { } } -func ReadAndConfirmPassword(types string) string { +func ReadAndConfirmPassword() string { for { - fmt.Printf("*** Enter an %s password: ", types) + fmt.Print("*** Enter a new password ") password, err := terminal.ReadPassword(syscall.Stdin) errors.CheckError(err) fmt.Print("\n") - fmt.Printf("*** Confirm the %s password: ", types) + fmt.Print("*** Confirm the new password ") confirmPassword, err := terminal.ReadPassword(syscall.Stdin) errors.CheckError(err) fmt.Print("\n") @@ -426,7 +426,7 @@ func UpdateSettings(defaultPassword string, settingsMgr *SettingsManager, update if _, ok := cdSettings.LocalUsers[common.ArgoCDAdminUsername]; !ok || updateSuperuser { passwordRaw := defaultPassword if passwordRaw == "" { - passwordRaw = ReadAndConfirmPassword("admin") + passwordRaw = ReadAndConfirmPassword() } log.Infof("password set to %s", passwordRaw) hashedPassword, err := password.HashPassword(passwordRaw)