2626
2727
2828class AuthenticateAccessToken (show .ShowOne ):
29- """Authenticate access token - receive keystone token"""
29+ """Authenticate access token to receive keystone token"""
3030
3131 api = 'identity'
3232 log = logging .getLogger (__name__ + '.AuthenticateAccessToken' )
@@ -233,6 +233,36 @@ def take_action(self, parsed_args):
233233 return
234234
235235
236+ class DeleteUserAuthorization (command .Command ):
237+ """Delete user authorization command"""
238+
239+ log = logging .getLogger (__name__ + '.DeleteUserAuthorization' )
240+
241+ def get_parser (self , prog_name ):
242+ parser = super (DeleteUserAuthorization , self ).get_parser (prog_name )
243+ parser .add_argument (
244+ 'user' ,
245+ metavar = '<user>' ,
246+ help = 'Name or Id of user' ,
247+ )
248+ parser .add_argument (
249+ 'access_id' ,
250+ metavar = '<access-id>' ,
251+ help = 'Access Id to be deleted' ,
252+ )
253+ return parser
254+
255+ def take_action (self , parsed_args ):
256+ self .log .debug ('take_action(%s)' % parsed_args )
257+
258+ identity_client = self .app .client_manager .identity
259+ user = utils .find_resource (
260+ identity_client .users , parsed_args .user ).id
261+ identity_client .oauth .delete_authorization (user ,
262+ parsed_args .access_id )
263+ return
264+
265+
236266class ListConsumer (lister .Lister ):
237267 """List consumer command"""
238268
@@ -249,6 +279,37 @@ def take_action(self, parsed_args):
249279 ) for s in data ))
250280
251281
282+ class ListUserAuthorizations (lister .Lister ):
283+ """List user authorizations command"""
284+
285+ log = logging .getLogger (__name__ + '.ListUserAuthorizations' )
286+
287+ def get_parser (self , prog_name ):
288+ parser = super (ListUserAuthorizations , self ).get_parser (prog_name )
289+ parser .add_argument (
290+ 'user' ,
291+ metavar = '<user>' ,
292+ help = 'Name or Id of user' ,
293+ )
294+ return parser
295+
296+ def take_action (self , parsed_args ):
297+ self .log .debug ('take_action(%s)' % parsed_args )
298+
299+ identity_client = self .app .client_manager .identity
300+ user = utils .find_resource (
301+ identity_client .users , parsed_args .user ).id
302+
303+ columns = ('Access Key' , 'Consumer Key' , 'Issued At' ,
304+ 'Project Id' , 'User Id' , 'Requested Roles' )
305+ data = identity_client .oauth .list_authorizations (user )
306+ return (columns ,
307+ (utils .get_item_properties (
308+ s , columns ,
309+ formatters = {},
310+ ) for s in data ))
311+
312+
252313class SetConsumer (command .Command ):
253314 """Set consumer command"""
254315
@@ -284,6 +345,30 @@ def take_action(self, parsed_args):
284345 return
285346
286347
348+ class ShowAuthorizationPin (show .ShowOne ):
349+ """Show Authorization pin command"""
350+
351+ log = logging .getLogger (__name__ + '.ShowAuthorizationPin' )
352+
353+ def get_parser (self , prog_name ):
354+ parser = super (ShowAuthorizationPin , self ).get_parser (prog_name )
355+ parser .add_argument (
356+ 'request_id' ,
357+ metavar = '<request-id>' ,
358+ help = 'Show pin for request token' ,
359+ )
360+ return parser
361+
362+ def take_action (self , parsed_args ):
363+ self .log .debug ('take_action(%s)' % parsed_args )
364+ identity_client = self .app .client_manager .identity
365+ data = identity_client .oauth .get_authorization_pin (
366+ parsed_args .request_id )
367+ info = {}
368+ info .update (data ._info )
369+ return zip (* sorted (info .iteritems ()))
370+
371+
287372class ShowConsumer (show .ShowOne ):
288373 """Show consumer command"""
289374
0 commit comments