@@ -392,14 +392,41 @@ def get_parser(self, prog_name):
392392 metavar = '<new-password>' ,
393393 help = 'New user password'
394394 )
395+ parser .add_argument (
396+ '--original-password' ,
397+ metavar = '<original-password>' ,
398+ help = 'Original user password'
399+ )
395400 return parser
396401
397402 @utils .log_method (log )
398403 def take_action (self , parsed_args ):
399404 identity_client = self .app .client_manager .identity
400405
401- current_password = utils .get_password (
402- self .app .stdin , prompt = "Current Password:" , confirm = False )
406+ # FIXME(gyee): there are two scenarios:
407+ #
408+ # 1. user update password for himself
409+ # 2. admin update password on behalf of the user. This is an unlikely
410+ # scenario because that will require admin knowing the user's
411+ # original password which is forbidden under most security
412+ # policies.
413+ #
414+ # Of the two scenarios above, user either authenticate using its
415+ # original password or an authentication token. For scenario #1,
416+ # if user is authenticating with its original password (i.e. passing
417+ # --os-password argument), we can just make use of it instead of using
418+ # --original-password or prompting. For scenario #2, admin will need
419+ # to specify --original-password option or this won't work because
420+ # --os-password is the admin's own password. In the future if we stop
421+ # supporting scenario #2 then we can just do this.
422+ #
423+ # current_password = (parsed_args.original_password or
424+ # self.app.cloud.password)
425+ #
426+ current_password = parsed_args .original_password
427+ if current_password is None :
428+ current_password = utils .get_password (
429+ self .app .stdin , prompt = "Current Password:" , confirm = False )
403430
404431 password = parsed_args .password
405432 if password is None :
0 commit comments