/** * Creates a type that requires to verify that user has the read permission * when searching for documents. * * Both types {@code typeName} and "authorization" are created. Documents * must be created with _parent and _routing having the parent uuid as values. * * @see NewIndex.NewIndexType#requireProjectAuthorization() */ private static NewIndex.NewIndexType enableProjectAuthorization(NewIndex.NewIndexType type) { type.setAttribute("_parent", ImmutableMap.of("type", TYPE_AUTHORIZATION)); type.setAttribute("_routing", ImmutableMap.of("required", true)); NewIndex.NewIndexType authType = type.getIndex().createType(TYPE_AUTHORIZATION); authType.setAttribute("_routing", ImmutableMap.of("required", true)); authType.createLongField(FIELD_GROUP_IDS); authType.createLongField(FIELD_USER_IDS); authType.createBooleanField(FIELD_ALLOW_ANYONE); authType.setEnableSource(false); return type; }
/** * Creates a type that requires to verify that user has the read permission * when searching for documents. * It relies on a parent type named "authorization" that is automatically * populated by {@link org.sonar.server.permission.index.PermissionIndexer}. * * Both types {@code typeName} and "authorization" are created. Documents * must be created with _parent and _routing having the parent uuid as values. * * @see NewIndex.NewIndexType#requireProjectAuthorization() */ public static NewIndex.NewIndexType enableProjectAuthorization(NewIndex.NewIndexType type) { type.setAttribute("_parent", ImmutableMap.of("type", TYPE_AUTHORIZATION)); type.setAttribute("_routing", ImmutableMap.of("required", true)); NewIndex.NewIndexType authType = type.getIndex().createType(TYPE_AUTHORIZATION); authType.setAttribute("_routing", ImmutableMap.of("required", true)); authType.createLongField(FIELD_GROUP_IDS); authType.createLongField(FIELD_USER_IDS); authType.createBooleanField(FIELD_ALLOW_ANYONE); authType.setEnableSource(false); return type; }