diff --git a/pillar/application/modules/service.py b/pillar/application/modules/service.py index 01f14dbc..db8525d1 100644 --- a/pillar/application/modules/service.py +++ b/pillar/application/modules/service.py @@ -21,13 +21,19 @@ def badger(): # Parse the request args = request.json - action = args['action'] - user_email = args['user_email'] - role = args['role'] + action = args.get('action', '') + user_email = args.get('user_email', '') + role = args.get('role', '') if action not in {'grant', 'revoke'}: raise wz_exceptions.BadRequest('Action %r not supported' % action) + if not user_email: + raise wz_exceptions.BadRequest('User email not given') + + if not role: + raise wz_exceptions.BadRequest('Role not given') + log.info('Service account %s %ss role %r to/from user %s', g.current_user['user_id'], action, role, user_email)