# How to pass specific characters password to ElasticSearch through Sulu/ArticleBundle

**URL:** <https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [February 5, 2024, 2:44pm UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544 "2024-02-05T14:44:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agdi](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Agdi](https://discuss.elastic.co/u/Agdi)\
**Post date:** [February 5, 2024, 2:44pm UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/1 "2024-02-05T14:44:38Z")

</div>

### Elasticsearch Version

6.8.0

### Installed Plugins

Sulu - SuluArticle/Bundle

### Java Version

_bundled_

### OS Version

Ubuntu 20.04

### Problem Description

I'm working on a project using Sulu 2.4.15 - php 8.2 - Symfony 5.5 - Sulu/Article-bundle 2.5.1

I usually use Elasticsearch with Sulu, which is recommended as standard. But until now, I've never secured the Elasticsearch connection via login/password.  
For this project, our customer is imposing a password made up of special characters, but I can't get in.  
For my example, I have an elastic 6.8.0 image:

 ![Capture d’écran de 2024-02-01 13-46-28](https://us1.discourse-cdn.com/elastic/original/3X/7/7/7788b8f85ab47c71be410fb4931a64d0054a79df.png)  
The password is "toto?"  
When I access my ES via Curl by encoding the password ( toto%3F ) I have no problem:  
 ![Capture d’écran de 2024-02-01 13-48-46](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e3b3c9e508ec1abd51211a95c56a055a17012b9c.png)

But when I try to run a command that requires connecting to Elasticsearch from Sulu/ArticleBundle, like a sulu:article:reindex , I can't authenticate (1st screen is my .env.local, 2nd screen is the command on the left / the logs of ES on the right)

 ![Capture d’écran de 2024-02-01 13-53-00](https://us1.discourse-cdn.com/elastic/original/3X/5/0/50de67d485dc5b0425dc2f2090da1aa5994bd508.png)

 ![Capture d’écran de 2024-02-01 13-53-33](https://us1.discourse-cdn.com/elastic/original/3X/0/f/0f349c5a7ea5aed0e64894b89452d1deb1a78543.png)

However, if I set the password in my ES docker to "toto" and remove %3F from my .env url, I don't have any connection problems. The problem comes from the special character "?

Digging through the error messages, I came across this file :  
vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/Connection.php

And I realized that just before the query, the string was not decoded. If I modify it manually at this point, either by using an urldecode function or by hard-coding it, then I'm able to connect & do my reindex : (lines 235 and 236 both operate) :

 ![Capture d’écran de 2024-02-01 13-58-01](https://us1.discourse-cdn.com/elastic/original/3X/b/e/be13820235f2fba83907b577d40b532608b64de7.png)

But I don't understand why I need to manually "urldecode" my string, and this solution isn't viable since it's in the vendor/ folder.

I feel like I've searched in multiple places, asked on Slack Sulu, but I can't find any answer for what seems to be a very basic concern.

I've already tried it in my .env :

ELASTICSEARCH\_HOST=[http://elastic:toto%3F@127.0.0.1:9200](http://elastic:toto%3F@127.0.0.1:9200)  
ELASTICSEARCH\_HOST="[http://elastic:toto%3F@127.0.0.1:9200](http://elastic:toto%3F@127.0.0.1:9200)"  
ELASTICSEARCH\_HOST=[http://elastic:toto?@127.0.0.1:9200](http://elastic:toto?@127.0.0.1:9200)  
ELASTICSEARCH\_HOST=[http://elastic:toto\%3F@127.0.0.1:9200](http://elastic:toto%5C%3F@127.0.0.1:9200)  
ELASTICSEARCH\_HOST=[http://elastic:toto\?@127.0.0.1:9200](http://elastic:toto%5C?@127.0.0.1:9200)  
ELASTICSEARCH\_HOST=[http://elastic:toto%%3F@127.0.0.1:9200](http://elastic:toto%25%3F@127.0.0.1:9200)  
etc...

Thanks a lot !

### Steps to Reproduce

Install ES 6.8.0 :

```auto
cat docker-compose.yml 
version: '3,7'

services:
  elasticsearch:
   image: elasticsearch:6.8.0
   ports:
     - 9200:9200
   environment:
     - discovery.type=single-node
     - ELASTIC_PASSWORD=toto?
     - xpack.security.enabled=true

```

Install a 2.5 Sulu project : [Welcome to the Sulu Documentation! — Sulu 2.5 documentation](https://docs.sulu.io/en/2.5/)  
Install Sulu/ArticleBundle 2.5 : [GitHub - sulu/SuluArticleBundle: Bundle for managing localized content-rich entities like blog-posts in the Sulu content management system](https://github.com/sulu/SuluArticleBundle)

Try a command like

`bin/console sulu:article:reindex`

### Logs (if relevant)

![Capture d’écran de 2024-02-01 14-03-21](https://us1.discourse-cdn.com/elastic/optimized/3X/0/6/06a71829e31bb2de81e9e9b7a065fd36317e1769_2_690x25.png)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 5, 2024, 5:52pm UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/2 "2024-02-05T17:52:28Z")

</div>

Welcome!

This version is a way too old and you should not use it anymore.  
Please use at least 7.17 or better 8.12!

---

<div class="post-metadata">

**Author:** ![Agdi](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Agdi](https://discuss.elastic.co/u/Agdi)\
**Post date:** [February 5, 2024, 8:29pm UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/3 "2024-02-05T20:29:58Z")

</div>

Hi David ! I forgot to mention that i also tried with a new sulu project and a 7.17 ES image on my docker-compose, but the problem is the same.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 5, 2024, 9:20pm UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/4 "2024-02-05T21:20:33Z")

</div>

May be wrap the password with double quotes?

If you try with 7.17, please share the fiull details and please don't post images of text as it's hard to read and is not searchable.

Thanks

---

<div class="post-metadata">

**Author:** ![Agdi](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Agdi](https://discuss.elastic.co/u/Agdi)\
**Post date:** [February 6, 2024, 9:02am UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/5 "2024-02-06T09:02:17Z")

</div>

I already tried with double quotes.

Here is the docker-compose for the 7.17 image :

```auto
cat docker-compose.yml 
version: '3,7'

services:
  elasticsearch:
   image: docker.elastic.co/elasticsearch/elasticsearch:7.17.17
   ports:
     - 9200:9200
   environment:
     - discovery.type=single-node
     - ELASTIC_PASSWORD=toto?
     - xpack.security.enabled=true

```

And i get the same result in a brand new Sulu Project : When i try to, for example, create an index, i got this error :

```auto
{"error":{"root_cause":[{"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/su_articles?include_type_name=true]","header":{"WWW-Authenticate":"Basic realm=\"security\" ch  
  arset=\"UTF-8\""}}],"type":"security_exception","reason":"unable to authenticate user [elastic] for REST request [/su_articles?include_type_name=true]","header":{"WWW-Authenticate":"Basic realm=\"security\" charset  
  =\"UTF-8\""}},"status":401}

```

And on the Log of the docker :

```auto
elasticsearch-elasticsearch-1 | {"type": "server", "timestamp": "2024-02-06T08:56:30,405Z", "level": "INFO", "component": "o.e.x.s.a.RealmsAuthenticator", "cluster.name": "docker-cluster", "node.name": "131fb8b51258", "message": "Authentication of [elastic] was terminated by realm [reserved] - failed to authenticate user [elastic]", "cluster.uuid": "Ht_U5OURSvSD0NyCIRNXDw", "node.id": "xE6rXeH3SPW5YB6yvB-hmQ" }

```

But once again, if i modify the file vendor/elasticsearch/elasticsearch/src/Elasticsearch\>Connections\>Connection.php ligne 262 and i add either this one :

```auto
$request['client']['curl'][10005] = "elastic:toto?";

```

or this one

```auto
$request['client']['curl'][10005] = urldecode($request['client']['curl'][10005]);

```

Then it works !

But well, i cannot modify and push a vendor folder, so i don't really know what to do ☹

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 6, 2024, 9:21am UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/6 "2024-02-06T09:21:20Z")

</div>

Everything works on Elasticsearch side. I tried your compose file and then I ran:

```auto
david@mbp-de-david discuss-xxx % curl -u elastic http://localhost:9200
Enter host password for user 'elastic':

```

I typed `toto?`

```auto
{
  "name" : "c7bc3d5d73e4",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "15urBLx-RtOD-WgeCz9SOw",
  "version" : {
    "number" : "7.17.17",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "aba4da413a368e296dfc64fb20897334d0340aa1",
    "build_date" : "2024-01-18T10:05:03.821431920Z",
    "build_snapshot" : false,
    "lucene_version" : "8.11.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

```

```auto
curl -u "elastic:toto?" http://localhost:9200

```

Also worked well.

So this is not something you can solve on Elasticsearch side as it behaves correctly but check your code or the library you are using.

---

<div class="post-metadata">

**Author:** ![Agdi](https://avatars.discourse-cdn.com/v4/letter/a/a8b319/32.png) [@Agdi](https://discuss.elastic.co/u/Agdi)\
**Post date:** [February 6, 2024, 9:24am UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/7 "2024-02-06T09:24:18Z")

</div>

Yes that's my problem, with Curl it works fine but using the ArticleBundle it doesn't. But I don't know who to ask since on the Sulu slack I can't get an answer ☹  
Thanks anyway

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 5, 2024, 9:25am UTC](https://discuss.elastic.co/t/how-to-pass-specific-characters-password-to-elasticsearch-through-sulu-articlebundle/352544/8 "2024-03-05T09:25:00Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
