Should I query the ref: urls in the ldapsearch output? - openldap

When doing an ldapsearch from a script, I will get some lines with
# search reference
ref: ldap://<url>/<baseDn>
Am I supposed to do the same query to these servers or just stick with the values returned from the original query?
If I do an ldapsearch and receive a status code of 10, then that is a referral and I would definitely follow that.

Related

Linkedin get user feed

I try to get my linkedin feed using this API :
https://linkedin.api-docs.io/v1.0/feed/42Hm9SaY2p2CGwPzp
I try to use this request : "GET /voyager/api/feed/updates" with this shell code :
curl --request GET \ --url
https://www.linkedin.com/voyager/api/feed/updates \ --data '{}'
But I get this response : "CSRF check failed". I understand why linledin respond this but how to avoid it ?
You missing headers, see API docs here: https://linkedin.api-docs.io/v1.0/feed and explanation how get headers here: https://towardsdatascience.com/using-browser-cookies-and-voyager-api-to-scrape-linkedin-via-python-25e4ae98d2a8
API docs a bit outdated, data output format might be different, this at least true for messaging/conversations, not sure about feed
In regards of headers I suggest to try apify.com and extract them in real time from browser instance (run puppeteer, login to LiN, get headers, save them)
Phantombuster will not allow you to use your own code so not very useful

How to send data to influxdb via post call without using curl?

i am new to influxdb and i was trying to add data to influx db . I found on the documentation page that it can be done using curl.
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
but i want to hit it from the browser and be able to insert data to influxdb.
For select query :
http://localhost:8086/query?db=mydb&q=select * from temperature
this is a url which can be used to get data from influxdb. Is there a similar way to insert data to influxdb.
I tried creating url from curl but wasn't successful.
little bit late but:
you should call REST via POST
url: http://localhost:8086/write?db=mydb
type :POST
body: measurement,value=123 thetime=1502474399000

Does Firebase REST streaming support ordering and filtering child nodes?

I would like to stream changes to a Firebase location, but filter the results based on a query to some index, like so:
curl -i -L -H "Accept: text/event-stream" https://mydata.firebaseio.com/path.json?'orderBy="myIndexedField"&equalTo="desiredValue"'
What I observe is that Firebase appears to ignore my query and proceeds to stream all changes to that location whether they match the query or not. Is there any way to do this, other than writing code to perform my own client-side filtering?
EDIT
Frank's answer below shows that Firebase does indeed honor your query parameters. The problem I'm having still persists, and I simply misconstrued what was going on, as the situation turns out to be a little more complicated. I've reproduced my issue in Frank's Firebase, which he was kind enough to supply as a live example for this question.
Here are the steps to reproduce my issue:
Start a streaming query with the constraint type == 1:
$ curl -i -L -H "Accept: text/event-stream" 'https://stackoverflow.firebaseio.com/29265457/.json?print=pretty&orderBy="type"&equalTo=1'
In a separate terminal, post a new item with type==1:
$ curl -X POST -H "Content-Type: application/json" -d '{"type": 1}' https://stackoverflow.firebaseio.com/29265457/.json
{"name":"-JlY1nAmymCKw5lvLvMe"}
This object pops up in my ongoing curl stream as expected, since it matches the query of type==1:
event: patch
data: {"path":"/","data":{"-JlY1nAmymCKw5lvLvMe":{"type":1}}}
Now, here's the part I misinterpreted as Firebase ignoring queries. If I PUT that resource I just POSTed and change it to type==0, it still shows up in my stream! To perform the PUT:
$ curl -X PUT -H "Content-Type: application/json" -d '{"type": 0}' https://stackoverflow.firebaseio.com/29265457/-JlY1nAmymCKw5lvLvMe.json
And here's what I see pop up in my ongoing stream curl:
event: patch
data: {"path":"/","data":{"-JlY1nAmymCKw5lvLvMe":{"type":0}}}
If I PUT "type" to 0 again, it no longer shows up in my curl stream terminal. If I PUT type to 1, then it does pop up in my curl stream (expected). It's the transition from 1->0 where I get the unexpected event.
Also, using PATCH instead of PUT to modify "type" appears to result in the same behavior in the curl stream.
I think it's natural to expect that when I change a value to NOT match my query anymore, I wouldn't see it in my stream. However, it looks like perhaps the query is being matched before the value is edited, or something along those lines... I have no idea how this is implemented on the Firebase end.
So I guess the new question is: How can I avoid seeing changed values that don't match my query in the REST stream?
There are two things that could be wrong here:
you didn't define an index on myIndexedField
your URL is quoted incorrectly
Ad 1) When you access Firebase through the (JavaScript/iOS/Java) libraries, it will fall back to client-side ordering and filtering if you're ordering/filtering data that is not indexed. Given that the REST API doesn't come with a client-library, it cannot perform such a fallback and it will simply return the data unordered/unfiltered.
Ad 2) you need to put your single quotes around the entire URL, not just the query string. An example curl that works for me:
curl -i -L -H "Accept: text/event-stream" 'https://stackoverflow.firebaseio.com/29265457/.json?orderBy="type"&equalTo=0'
I push data to it with this JavaScript snippet:
new Firebase('https://stackoverflow.firebaseio.com/29265457/').push({ type: 0 });
And it shows up in the curl window; or it doesn't if I set type to 1.

REST API endpoint - weird path parameter

I am learning REST API and URI design and I have found one here:
https://raw.githubusercontent.com/JeanVEGA/MI-MPR-DIP-Admission/master/examples/requests.sh
I have a few questions.
There is for example:
User.resetPassword, anonymous by User's {email}
curl -i -X POST http://localhost:9090/admission/services/user/person/email:{email}/reset_password
I do not understand construction email:{email}... what does it mean? It means that if I have String path param, I need to do it in this way?
The similar is here:
Term.get
curl -i -H "Accept: application/json" -H "X-CTU-FIT-Admission-Session: [session identifier from User.identity]" http://localhost:9090/admission/services/term/dateOfTerm:{dateOfTerm}/room:{room}
room:{room} - Is this because room should be for example 123ABC? So it is not a number so it need to be written in this way?
And my last question:
User.resetPassword for User by Admission Code, send notification to User's Email and this {email}
curl -i -H "X-CTU-FIT-Admission-Session: [session identifier from User.identity]" -X POST http://localhost:9090/admission/services/user/admission/{admissionCode}/person/email:{email}/reset_password
My poiont of question is "reset_password" ... I thought due to right design principles that no verb should be in URI... because if the verb is in URI, I thought that it means that resource is actually an operation.
That url can be only a resource identifier. So this is an url template which waits a unique email address as a parameter. A filled in template should look something like this:
./person/email:my#email.adr/reset_password
note:
The reset_password is not a valid REST resource (it describes a service not a resource) and the POST method is mostly for resource creation (not for update or partial update). Real REST requests look like this:
PUT ./person/email:{email}/password "newpass"
PUT ./person/{id}/password "newpass"
PUT ./person/email:{email}/identification_factors/password "newpass"
PATCH ./person/email:{email}/identification_factors {password: "newpass"}
and so on...

differentiate create and update of named resource in REST

I've read put-vs-post-in-rest through, and I know that PUT is for create and update specific resource with identifier given specifically in URL.
But if I'm going to strict the "update" operation with If-Match (which means user MUST provide valid ETag to update the resource), given that PUT is also used to create named resource, (which do not require If-Match), then the API will have to guess whether the PUT request means to update or to create by whether If-Match header is provided.
I know this can be done but I think it's weird. Are there other (more reasonable) ways to do this (by not using PUT maybe)?
Thanks.
UPDATE:
Here is my scenario for now:
# create the resource the first time
curl -X PUT -d '{"foo": "bar"}' /resource/r_id
# the resource already exists, so this will fail with a 4xx error
curl -X PUT -d '{"foo": "bar2"}' /resource/r_id
# must provide valid If-Match to make updates work
curl -X PUT -H 'If-Modefied: myetag' -d '{"foo": "bar2"}' /resource/r_id
# what makes it confusing is this:
# user want to make a new record, but /resource/r_id2 in fact exists
# the API will return an error message, should it be
# "creation failed -- already exist" or "update failed -- ETag not provided"?
curl -X PUT -d '{"foo": "bar"}' /resource/r_id2
It's not that this can't be done, it's just that I think this design(with PUT for both ETag-controlled update AND named creation) might be confusing, I personally think it's better if I use different vocabulary (not just PUT), but, I'm here asking what's the reasonable and RESTful way I can do this.
You could secure the PUT-to-create with "If-None-Match: *", see http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p4-conditional-26.html#rfc.section.3.2.p.7.
Also, you may want to consider using http://greenbytes.de/tech/webdav/rfc6585.html#status-428.
You may try to mimic well designed REST APIs.
For this feature, CouchDB designers chose to emit 409 Conflict as the status, and {"error":"conflict","reason":"Document update conflict."} as the body.
Nota bene: Remove "document" of course since it is specific to the application.
You don't need to restrict the update with If-Match. When you get a PUT, check your datastore. If a resource with the given id doesn't exist yet, create it. If it does, update it to have the given values.
What If-Match buys you is making sure that the resource hasn't changed in the datastore. You're trying to avoid this:
client 1: GET /resources/1
client 2: GET /resources/1
client 2: PUT /resources/1 with updates
client 1: PUT /resources/1 with updates

Resources