def post(self, uid, user, **kwargs): lock_id = kwargs['lockId'] security_utils.verify_lock_ownership(uid, lock_id) kwargs['password'] = security_utils.hash_password(kwargs['password']) password = Password.build(kwargs) return (password_manager.add_password(lock_id, password), LockPasswordResponse.code)
def put(self, uid, user, **args): lock_id = args['lockId'] security_utils.verify_lock_ownership(uid, lock_id) # TODO: refactor this into something less hacky than enum matching if args.get('status') != LockStatusEnum.OPEN_REQUESTED: error_message = 'Users cannot set the lock to open or closed. ' + \ 'Open or close the vault to do so.' raise AuthorizationException(error_message) was_lock_removed = False found_password = security_utils.verify_password( lock_id, args.get('password')) if found_password.type == PasswordType.OTP: password_manager.remove_password(lock_id, found_password) was_lock_removed = True result = lock_manager.change_lock_status( lock_id, args.get('status'), was_lock_removed), PutUserLockStatusResponse.code return result
def delete(self, uid, user, **kwargs): lock_id = kwargs['lockId'] security_utils.verify_lock_ownership(uid, lock_id) result = user_lock_manager.delete_user_lock(uid, lock_id) return result, UserLockResponse.code
def get(self, uid, user, **kwargs): lock_id = kwargs['lockId'] security_utils.verify_lock_ownership(uid, lock_id) events = history_manager.get_events_from_lock_id(lock_id) return ({'events': events}, LockHistoryResponse.code)
def delete(self, uid, user, **kwargs): lock_id = kwargs['lockId'] password_id = kwargs['passwordId'] security_utils.verify_lock_ownership(uid, lock_id) password_manager.remove_password_by_id(lock_id, password_id) return {}, 200
def get(self, uid, user, **kwargs): lock_id = kwargs['lockId'] password_id = kwargs['passwordId'] security_utils.verify_lock_ownership(uid, lock_id) return (password_manager.get_password_metadata(lock_id, password_id), LockPasswordResponse.code)
def get(self, uid, user, **kwargs): lock_id = kwargs['lockId'] security_utils.verify_lock_ownership(uid, lock_id) return lock_manager.get_lock_status( lock_id), UserLockStatusResponse.code
def get(self, uid, user, **kwargs): lock_id = kwargs['lockId'] security_utils.verify_lock_ownership(uid, lock_id) result = password_manager.get_passwords_metadata(lock_id), 200 return result