Can't access 8000 port after install Kong - api

Installed Kong with docker by official guide. Then add an API:
curl -i -X POST \
--url http://1.2.3.4:8001/apis/ \
--data 'name=test-api' \
--data 'hosts=1.2.3.4' \
--data 'upstream_url=http://1.2.3.4:3000'
Check API:
curl -i -X GET \
--url http://1.2.3.4:8001/apis/
{
"total": 1,
"data": [
{
"created_at": 1530076151932,
"strip_uri": true,
"id": "ab2ea516-ef44-4f00-a55f-4ed8bb0b69a0",
"hosts": [
"1.2.3.4"
],
"name": "test-api",
"http_if_terminated": false,
"https_only": false,
"retries": 5,
"preserve_host": false,
"upstream_connect_timeout": 60000,
"upstream_read_timeout": 60000,
"upstream_send_timeout": 60000,
"upstream_url": "http://1.2.3.4:3000"
}
]
}
However, can't get 8000 port:
curl -i -X GET \
--url http://1.2.3.4:8000/
--header 'Host: 1.2.3.4'
404 page not found
1.2.3.4 is the fake IP address.
From here got should use either request_host or request_path. But there isn't either of them in this case.
It's the newest version. What's wrong?

Related

I can't disable the user with the Keyrock API

I want to disable or enable the user found in keyrock with API, but I can't. https://keyrock.docs.apiary.io/ doesn't say how to do it here. Isn't that possible?enter image description here
Log in as an admin user via the REST API.
curl -iX POST \
'http://localhost:3005/v1/auth/tokens' \
-H 'Content-Type: application/json' \
-d '{
"name": "admin#test.com",
"password": "1234"
}'
The response header returns an X-Subject-token Header which identifies who has logged on the application. This token is required in all subsequent requests to gain access.
The image you give in the question is just a GUI version of the GET /users endpoint
curl -L -X GET 'http://localhost:3005/v1/users' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Or you can request a specific user:
curl -L -X GET 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
Returns:
{
"user": {
"scope": [],
"id": "bbbbbbbb-good-0000-0000-000000000000",
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": true,
"admin": false,
"image": "default",
"gravatar": false,
"date_password": "2018-07-30T11:41:14.000Z",
"description": "Bob is the regional manager",
"website": null
}
}
You want to set enabled: false using the PATCH /user endpoint.
curl -L -X PATCH 'http://localhost:3005/v1/users/bbbbbbbb-good-0000-0000-000000000000' \
-H 'Content-Type: application/json' \
-H 'X-Auth-token: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' \
--data-raw '{
"user": {
"username": "bob",
"email": "bob-the-manager#test.com",
"enabled": false,
"gravatar": false,
"date_password": "2018-07-26T15:25:14.000Z"
}
}'
More information can be found within the Security Chapter Tutorials
within the FIWARE documentation where Keyrock is a component found within the FIWARE Catalogue
In the FIWARE documentation an example is given using Keyrock to provide user identities around a "powered by FIWARE" solution. Note that whilst Keyrock is commonly used in "powered by FIWARE" solutions (along with other elements from the FIWARE Catalogue), it could also be used to provide identities for other independent applications or micro-services - it is not tightly bound to only be used in FIWARE scenarios. Similarly alternative open-source or proprietary components for security or identity management systems could be used to secure "powered by FIWARE" solution as well.

Get latest tag commit from bitbucket api 2.0

I am trying to create a utility tool for which I need to get the latest tag committed to a specific repo.
I have tried so far:
curl -X GET \
https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic encodedpasswd' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.bitbucket.org'
What I get in return is paginated response, like this:
{
"pagelen": 10,
"values": [
{
"name": "release-1.2",
"links": {
},
"tagger": {
},
"date": "2019-11-15T11:53:56+00:00",
"message": "[maven-release-plugin]copy for tag release-1.2\n",
"type": "tag",
"target": {
}
},
{
"name": "release-1.3",
"links": {
},
"tagger": {
},
"date": "2019-11-20T07:53:51+00:00",
"message": "[maven-release-plugin]copy for tag release-1.3\n",
"type": "tag",
"target": {
}
}
],
"page": 1
}
Now as per the documentation I have referred through here, tags are specially ordered when returned, but I am confused as to why the value release-1.3 is not first in the response. I think I am missing something. Or if this is the expected order, how can I achieve the tags sorted on date attribute, to get the latest tag.
So I was able to solve this by using sort on attribute target.date.
curl -X GET \
https://api.bitbucket.org/2.0/repositories/<team>/<reposlug>/refs/tags?sort=target.date \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Authorization: Basic encodedpasswd' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Host: api.bitbucket.org'

Creating a tag with the Bitbucket Server API fails

I'm trying to use the Bitbucket Server RST API to create a new tag for a specific commit (represented by a hash). Please note that I use basic auth but don't write it to my examples below. What I've got is an HTTP 500 response.
curl -XPOST 'http://<server>/rest/api/latest/projects/p1/repos/r1/tags' -d '{
   "name": "my-new-tag",
    "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}'
I also tried:
curl -XPOST 'http://<server>/2.0/repositories/username/r1/refs/tags' -d '{
   "name": "my-new-tag",
    "hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}'
But in this case the request ends up in an HTTP 404 and I think that's because this is not a Bitbucket Server URL.
You can try this way:
curl -X POST -k -H 'Content-Type: application/json' -s -u <Your Account>:<Your password> -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{
"name": "my-new-tag",
"target":{
"hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}
}'
or
curl -X POST -k -H 'Content-Type: application/json' Authorization: Basic <<Authentication String>>' -i 'https://api.bitbucket.org/2.0/repositories/username/r1/refs/tags' --data '{
"name": "my-new-tag",
"target":{
"hash": "0d2019c8e18f8c961cdb67cb27afb69b04f3a10b"
}
}'

Legacy Firebase conditions not working with curl

This call:
curl -X POST \
-H "Authorization: key=AAAAx4uYEXU:...e8EEq9aCv-pGWXIfyCp_lUp28mY" \
-H "Content-Type: application/json" \
-d '{ "data": {
"score": "5x1",
"time": "15:10"
},
"condition": "'dogs' in topics || 'cats' in topics",
"content_available": true
}' \
"https://fcm.googleapis.com/fcm/send"
Causes this error:
Invalid "condition" field: only support 'topics' conditions
I copied the condition field straight from the documentation... how can I get this to work?

ICINGA2 API Not making host modification

i have problem with the API of ICINGA2.
i'm trying to add new variables with the POST call ,
i'm getting the required result,
But ICINGA2 didn't add the new var.
According to documentation:
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/icinga2-api
With the following API, i creates all our hosts in vienna :
curl -k -s -u root:icinga -H 'Accept: application/json' -X PUT 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh" } }' \
| python -m json.tool
While this part works as expected,
The problem is once host created, i need to add various vars for different servers.
for example
Adding of the variable: "vars.servicename" : "DHCP_Servers"
If i'm going back to the documentation, the below API that will need to be execute:
curl -k -s -u root:icinga -H 'Accept: application/json' -X POST 'https://localhost:5665/v1/objects/hosts/server.example.com' \
-d '{ "templates": [ "generic-host" ], "attrs": { "zone": "Vienna", "address": "180.33.1.123", "check_command": "hostalive", "vars.os" : "Linux", "vars.agent" : "ssh", "vars.servicename" : "DHCP_Servers" } }' \
| python -m json.tool
When i ran the API , as expected i'm getting back:
{
"results": [
{
"code": 200.0,
"name": "server.example.com",
"status": "Attributes updated.",
"type": "Host"
}
]
}
But there is no changes that taking place on ICINGA/ host file.
Obviously the same user as in my inbox and the forums (https://monitoring-portal.org/index.php?thread/37160-adding-vars-with-api/&postID=234885#post234885) lately. Leaving this as a note here as it might help others to see why it does not work. That feature is just not implemented as it involves storing the applied changes, do a rollback, and re-apply. Not as simple as it sounds.
https://dev.icinga.org/issues/11501