def get_all(
        self,
        requester_user,
        prefix=None,
        scope=None,
        user=None,
        decrypt=False,
        sort=None,
        offset=0,
        limit=None,
        **raw_filters,
    ):
        """
        List all keys.

        Handles requests:
            GET /keys/
        """
        if not scope:
            # Default to system scope
            scope = FULL_SYSTEM_SCOPE

        if user:
            # Providing a user implies a user scope
            scope = FULL_USER_SCOPE

        if not requester_user:
            requester_user = UserDB(name=cfg.CONF.system_user.user)

        scope = get_datastore_full_scope(scope)

        if scope not in [ALL_SCOPE] + ALLOWED_SCOPES:
            raise ValueError("Invalid scope: %s" % (scope))

        # User needs to be either admin or requesting items for themselves
        self._validate_decrypt_query_parameter(
            decrypt=decrypt, scope=scope, requester_user=requester_user
        )

        current_user = requester_user.name
        user = user or requester_user.name

        rbac_utils = get_rbac_backend().get_utils_class()

        # Validate that the authenticated user is admin if user query param is provided
        rbac_utils.assert_user_is_admin_if_user_query_param_is_provided(
            user_db=requester_user, user=user, require_rbac=True
        )

        from_model_kwargs = {"mask_secrets": not decrypt}

        if scope and scope not in ALL_SCOPE:
            self._validate_scope(scope=scope)
            raw_filters["scope"] = scope

        # Check if user is granted one of the system roles.
        has_system_role = rbac_utils.user_has_system_role(user_db=requester_user)

        # Check that an admin user has permission to all system scoped items.
        if has_system_role and scope in [ALL_SCOPE, SYSTEM_SCOPE, FULL_SYSTEM_SCOPE]:
            rbac_utils.assert_user_has_resource_db_permission(
                user_db=requester_user,
                resource_db=KeyValuePairDB(scope=FULL_SYSTEM_SCOPE),
                permission_type=PermissionType.KEY_VALUE_PAIR_LIST,
            )

        # Check that user has permission to user scoped items for provided user or current user.
        if user and scope in [ALL_SCOPE, USER_SCOPE, FULL_USER_SCOPE]:
            rbac_utils.assert_user_has_resource_db_permission(
                user_db=requester_user,
                resource_db=KeyValuePairDB(scope="%s:%s" % (FULL_USER_SCOPE, user)),
                permission_type=PermissionType.KEY_VALUE_PAIR_LIST,
            )

        # Set user scope prefix for the provided user (or current user if user not provided)
        # NOTE: It's very important raw_filters['prefix'] is set when requesting user scoped
        # items to avoid information leakage (aka user1 retrieves items for user2)
        name_for_keyref = ""
        if "name" in raw_filters and raw_filters["name"]:
            name_for_keyref = raw_filters["name"]
        else:
            name_for_keyref = prefix or ""

        user_scope_prefix = get_key_reference(
            name=name_for_keyref, scope=FULL_USER_SCOPE, user=user
        )

        # Special cases for ALL_SCOPE
        # 1. If user is an admin, then retrieves all system scoped items else only
        #    specific system scoped items that the user is granted permission to.
        # 2. Retrieves all the user scoped items that the current user owns.
        kvp_apis_system = []
        kvp_apis_user = []

        if scope in [ALL_SCOPE, SYSTEM_SCOPE, FULL_SYSTEM_SCOPE]:
            decrypted_keys = []
            # If user has system role, then retrieve all system scoped items
            if has_system_role:
                raw_filters["scope"] = FULL_SYSTEM_SCOPE
                raw_filters["prefix"] = prefix

                items = self._get_all(
                    from_model_kwargs=from_model_kwargs,
                    sort=sort,
                    offset=offset,
                    limit=limit,
                    raw_filters=raw_filters,
                    requester_user=requester_user,
                )

                kvp_apis_system.extend(items.json or [])
                if decrypt and items.json:
                    decrypted_keys.extend(
                        kv_api["name"] for kv_api in items.json if kv_api["secret"]
                    )
            else:
                # Otherwise if user is not an admin, then get the list of
                # system scoped items that user is granted permission to.
                for key in get_all_system_kvp_names_for_user(current_user):
                    try:
                        item = self._get_one_by_scope_and_name(
                            from_model_kwargs=from_model_kwargs,
                            scope=FULL_SYSTEM_SCOPE,
                            name=key,
                        )

                        kvp_apis_system.append(item)
                    except Exception as e:
                        LOG.error("Unable to get key %s: %s", key, str(e))
                        continue
                    if decrypt and item.secret:
                        decrypted_keys.append(key)
            if decrypted_keys:
                LOG.audit(
                    "User %s decrypted the values %s ",
                    user,
                    decrypted_keys,
                    extra={
                        "User": user,
                        "scope": FULL_SYSTEM_SCOPE,
                        "key_name": decrypted_keys,
                        "operation": "decrypt",
                    },
                )

        if scope in [ALL_SCOPE, USER_SCOPE, FULL_USER_SCOPE]:
            # Retrieves all the user scoped items that the current user owns.
            raw_filters["scope"] = FULL_USER_SCOPE
            if "name" in raw_filters and raw_filters["name"]:
                raw_filters["name"] = user_scope_prefix
            else:
                raw_filters["prefix"] = user_scope_prefix

            items = self._get_all(
                from_model_kwargs=from_model_kwargs,
                sort=sort,
                offset=offset,
                limit=limit,
                raw_filters=raw_filters,
                requester_user=requester_user,
            )

            kvp_apis_user.extend(items.json)
            if decrypt and items.json:
                decrypted_keys = [
                    kvp_api["name"] for kvp_api in items.json if kvp_api["secret"]
                ]
                if decrypted_keys:
                    LOG.audit(
                        "User %s decrypted the values %s ",
                        user,
                        decrypted_keys,
                        extra={
                            "User": user,
                            "scope": FULL_USER_SCOPE,
                            "key_name": decrypted_keys,
                            "operation": "decrypt",
                        },
                    )

        return kvp_apis_system + kvp_apis_user

        List all keys.

        Handles requests:
            GET /keys/
        
st2api/st2api/controllers/v1/keyvalue.py