Skip to content

Commit

Permalink
UserBoolQueryBuilder#FIELDS_ALLOWED_TO_QUERY
Browse files Browse the repository at this point in the history
  • Loading branch information
albertzaharovits committed Jun 13, 2024
1 parent 762b32d commit bde986f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public final class ApiKeyBoolQueryBuilder extends BoolQueryBuilder {

private static Set<String> FIELDS_ALLOWED_TO_QUERY = Set.of("_id", "doc_type", "type");
private static final Set<String> FIELDS_ALLOWED_TO_QUERY = Set.of("_id", "doc_type", "type");

private ApiKeyBoolQueryBuilder() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore;

import java.io.IOException;
import java.util.Set;

import static org.elasticsearch.xpack.security.support.FieldNameTranslators.USER_FIELD_NAME_TRANSLATORS;

public final class UserBoolQueryBuilder extends BoolQueryBuilder {

private static final Set<String> FIELDS_ALLOWED_TO_QUERY = Set.of("_id", User.Fields.TYPE.getPreferredName());

private UserBoolQueryBuilder() {}

public static UserBoolQueryBuilder build(QueryBuilder queryBuilder) {
Expand Down Expand Up @@ -50,8 +53,6 @@ protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws
}

boolean isIndexFieldNameAllowed(String fieldName) {
return "_id".equals(fieldName)
|| User.Fields.TYPE.getPreferredName().equals(fieldName)
|| USER_FIELD_NAME_TRANSLATORS.isIndexFieldSupported(fieldName);
return FIELDS_ALLOWED_TO_QUERY.contains(fieldName) || USER_FIELD_NAME_TRANSLATORS.isIndexFieldSupported(fieldName);
}
}

0 comments on commit bde986f

Please sign in to comment.