koopjs / koop-provider-elasticsearch

A provider for koop that can connect to one or more elastic search instances and turn indices/aliases into individual feature services.
Apache License 2.0
13 stars 4 forks source link

Is it possible to pass a user/password authentification with the provider ? #46

Closed FoicikRemi closed 2 weeks ago

FoicikRemi commented 2 years ago

Hello everyone !

I'm Remi from France, I'm working for the city of Versailles and I'm highly interested by this provider.

My main problematic is : We have several smart cities components connected to an elastic search database, we wanted to connect to index in this database without making replication in order to visualize datas with a map server in webmap, dashboard etc.... I understood that it could be possible with koop and this provider, am I right ?

I have actually some difficulties with using this provider. My first question is : Is it possible to connect to es with a user/password authentification ? I couldn't find an example with this issue and I tried naively to add a password variable in the esConnection class inside the default.json file.....

I'm really sorry in advance that I can't contribute with the coding part but I can maybe use some time in order to write some more "user friendly", detailed documentation if you're interested.

Best regard,

Rémi

qQsss777 commented 2 years ago

Hi Remi, looking at the code it looks like this feature is implemented : https://github.com/koopjs/koop-provider-elasticsearch/blob/master/src/utils/elasticConnectUtil.js#L31.

So try ( i didn't try) to add username and password keys to your esNameForServiceURLs object in your config file. For example:

{
  "esConnections": {
    "esNameForServiceURLs": {
      "id": "esNameForServiceURLs",
      "userName": "mysusername",
      "password": "mypassword",
      "protocol": "http://",
      "port": 9200,
      "hosts": [
        "localhost"
      ],
      "shapeIndices": {
        "states": {
          "geometryField": "geometry",
          "geometryType": "Polygon",
          "joinField": "NAME"
        }
      },
...
}
FoicikRemi commented 2 years ago

Hi Mark,

Thanks for your response. I saw this file but I wanted to be sure it was fully implemented.

I generated my app, I added Es provider

image

Here's the configuration of the es provider in "C:\Users\remi.foicik\testitoune\node_modules\@koopjs\provider-elasticsearch\config\default.json"

image

Then I can start the app with koop server or nmp start commands,

image

image

But now, I have no idea how to construct the output URL .....

For example, in the Github provider, I could follow this image

When I make some try, I get this error and the node stop working...

For example : 'http://localhost:8080/es/rest/services/localhost/versailles/MapServer' image

I really don't know where is the problem, the app itself, the es config file, the es connexion itself ?

Does anyone have a functional app I can use as an example please ? With output URL. It can really help me resolving my issues.

Best regards,

Rémi

qQsss777 commented 2 years ago

Can you modify versailles key with that :

"versailles":{
      "id": "versailles",
      "protocol": "http://",
      "port": 9200,
      "hosts": [
        "172.28.4.240"
      ],
      ... other keys/values
}
FoicikRemi commented 2 years ago

I also tried this way, the main problem is I don't understand what is the Output URL in order to test.

qQsss777 commented 2 years ago

did you try http://localhost:8080/es/172.28.4.420/versailles/FeatureServer' ?

zakhtar1998 commented 2 years ago

@FoicikRemi the url in your case would be http://localhost:8080/es/rest/services/versailles/winext/FeatureServer. Give this a try and let me know if you can retrieve the geo_point json.