Using NEST, Index documents in ElasticSearch which is authenticated using Jetty - elasticsearch

I have authenticated a machine which hosts Elastic Search, using Jetty plugin. Everything works fine with respect to security. But my problem is I need to add documents / update documents in the same index which is secured using Jetty. In NEST I tried to find anything related to a method connecting uri(secured by jetty) with username and password to index my data. But no method or API helps out.
I need to know "Whether NEST supports, indexing Elastic Search secured by Jetty" and if answer is yes, then please tell how it can be done.
Thanks,
PDK

Can you try putting the username/password in the URI that you are using to connect to your Jetty secured Elasticsearch index.
http://username:password#elasticsearchhost:9200
Since you are required to pass a Uri object to the ConnectionSettings for NEST you can set it like the following:
(Updated 4/25/14 - reflect correct usage with Uri class.)
var uri = new Uri("http://username:password#elasticsearchhost");
var client = new ElasticClient(new ConnectionSettings(uri));

Related

Elasticsearch search locked with ransomeware

I have not protected elasticsearch, so someone hacked it, left new index with contents where to transfer bitcoins. Data I can regenerate, the questions is how can I get rid of that. Accessing the indices directly works, but search scripts return http code 400 when I do curl requests with php. Any ideas?
edit:
I removed the folder and created index from the beginning. It did not fix anything.
You need Fresh Installation with proper security, use xPack or Communication method over private IP Rather using Public IP.

Handle different URL patterns in Zuul filters

I have two types of URL patterns as below.
/gateway/secure/api/user/getUser
/gateway/nonsecure/api/user/getUser
(Context root of zuul gateway application is gateway)
Using zuul filters I'm trying to implement two different logics based on secure and nonsecure URL patterns. I've written a pre-filter and seems it's not even executing that filter for above URL patterns. I could see gateway is throwing 404. When I try to access microservice without secure or nonsecure its working as expected. Below are the property changes I've done so far.
Context root of downstream microservice is api/user
zuul.prefix=/secure
zuul.routes.user.path=/api/user/**
zuul.routes.user.service-id=user
zuul.prefix=/nonsecure
zuul.routes.user.path=/api/user/**
zuul.routes.user.service-id=user
I've already tried by giving zuul.prefix and it seems prefix is setting as globally and cant apply only for specific routes. How can I achieve this? Can anyone please advice.Thanks
As you noted, the zuul.prefix property affects all mappings and can only be defined once. So, drop the zuul.prefix property and add the corresponding prefix to each zuul.routes.*.path properties:
zuul.routes.user.path=/secure/api/user/**
zuul.routes.user.service-id=user
zuul.routes.user.path=/nonsecure/api/user/**
zuul.routes.user.service-id=user
Note that, according to the documentation:
zuul.stripPrefix only applies to the prefix set in zuul.prefix. It does not have any effect on prefixes defined within a given route’s path.

Marklogic Spring Boot - Installing a Rest Endpoint

I am currently using the Marklogic spring boot demo. So far I have been able to add indexes, facets, front-end logic etc just fine.
Right now, I am trying to layer in some semantic logic into a rest endpoint.
I wrote a simple query into the query console, and attempted to add it to the src/main/ext folder so that it would get deployed by the ml-gradle bootrun.
Right now. This file will get deployed to the test-modules database, and is visible once saved (I can see it in explorer under URI /ext/my-endpoint. I also tried adding a folder named rest-api but that just adds it to /ext/rest-api/my-endpoint
At the top of the endpoint I have it declared as
`module namespace ext = "http://marklogic.com/rest-api/resource/my-endpoint";
However when I navigate to the URL it should be living at http://localhost:8090/LATEST/resources/my-endpoint?
It tells me it does not exist.
So I can see it in the modules database, but I can't use it on HTTP. the Query works in the query console (and is rather trivial, and-query of json-property-word-queries)
My question is:
How can I properly update the marklogic-spring-boot framework to properly deploy rest endpoints.
So I figured it out it seems.
Manually creating the file isn't registering the distribution workflow properly.
Instead I create the resource using ml-gradle
gradle mlCreateResource -PresourceName=my_endpoint
This will create a new folder called services, and create the endpoint for me, which can then have code over written.
Still not sure what gradle is doing special, so I can know what the proper way to do this manually would be, but at least it works.

Spring social and facebook api 2.4

I'm using spring-social for facebook, <version>2.0.1.RELEASE</version> and it works fine if I use the 2.3 Facebook version API.
I create a new app with the version 2.4 and it doesn’t work correctly, since FB changed the API policies:
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance:
To help improve
performance on mobile network connections, we've reduced the number of
fields that the API returns by default. You should now use the
?fields=field1,field2 syntax to declare all the fields you want the
API to return.
For example the post contains only the id and message and not from-name and from-id, so the class Post contains only this two fields.
Now to read this value we need to add “?fields=from”.
The question is, is there a way to use spring social also with the version 2.4 ?
It seems that the problem persists. So, I am using as workaround the following method to bring back the fields I need:
Facebook facebook = new FacebookTemplate(accessToken);
Post post = facebook.fetchObject(postId, Post.class, "picture, message, source, story, caption, place, description, type, from, link, icon, shares, created_time, name");

Spring Data Rest different data for same object depending on uri /files <-> files/1

I have problem with Spring-DATA-REST. I allready posted in the spring forum but got no answer. Maybe here someone can help?
I have a test application set up with Spring-DATA-REST and all my domain objects get exposed by spring data rest.
Now: If I access my files repository under the uri /files/ I get a list of files I just created.
But: If I then access one of the files with the direct uri /files/{id}, for example /files/1
I get data from a file I entered long ago. I can't explain where this data comes from...
I just checked the JpaRepository. That is ok and I get the same data from a file retrieved with:
JpaRepository.findAll().get(0) as from
jpaRepository.findOne(JpaRepository.getAll().get(0).getId())
Is there some cache in spring data rest, that could still have the old data?
I am really desperate. Anyone has an idea on how to get my new data with spring data rest?
I assume that you are using HTTP as a transfer layer. If yes then you should look at HTTP cache headers in response. The result may be cached somewhere between.
You may use:
curl -vvl uri/files/{id}
to see all response's headers.

Resources