Filtering requests by header - GunDB - token

So, basically I would like to filter the requests between nodes using some kind of security. I think a simple static token access based scenario is enough. The idea is to not let anyone to just connect and consult sensitive data. I already tried this solution, but I think it's outdated: JWT authentication with gundb.
Really appreciate some help :)
OBS: Im using the latest version of gundb. My server is the nodejs vanilla. Here's my code, but I dont know if it helps
const GUN = require('gun');
var listOfPeers = ["http://localhost:8081/gun"];
const server = require('http').createServer().listen(8080);
const gun = GUN({web: server, peers: listOfPeers});
gun.get("poems/2").put({foo: "bar"})

Related

Reading stream Mqtt

I need your help, look the following code:
result = _modem->AWSMQTTSend(topicGet, jsonSend);
readSize = _modem->AWSMQTTReadStream(dataRec, 3072);
I have obtained like response of "AWSMQTTSend" result=0, which mean correct, but i dont get response of "AWSMQTTReadStream", supposedly here I should receive the bytes sent by the AWS platform.
I don't know if it's missing set up some policy or other data on the platform for this works.
I thank you so much for your help.

KairosDB Java client checks health

I would like to use KairosDB Java client to check KairosDB health but it seems there is too few guides. Anyone knows please help me?
I have commented the question to get more details about what you want to do.
However one interesting metric is the HTTP request time in kairosDB (kairosdb.http.request_time). By polling this metric you will:
- Make sure metrics are recorded
- Make sure http requests are received, processed and answered in reasonable time (although long queries will report longer time than others)
To do so you can follow the example on https://github.com/kairosdb/kairosdb-client, e.g. by doing this kind of query every five minutes:
QueryBuilder builder = QueryBuilder.getInstance();
builder.setStart(10, TimeUnit.MINUTES)
.setEnd(0, TimeUnit.MINUTES)
.addMetric("kairosdb.http.request_time")
.addGrouper(new TagGrouper("host"));
HttpClient client = new HttpClient("http://localhost:8080");
QueryResponse response = client.query(builder);
client.shutdown();
I hope this helps.
Regards,
Loic

How would I create a HTTPS request in vala?

I am trying to create a github issue app in vala and need to get the list of issues from https://api.github.com/repos/vmg/redcarpet/issues?state=closed.
I have tried using this example in my code but this is not working for SSL.
https://wiki.gnome.org/Projects/Vala/GIONetworkingSample
I have also tried soup but this seems to have a problem where it can't find its dev headers.
Any help would be much appreciated.
You have to set the tls property to true on the SocketClient object, and
you have to connect to the correct port (443). This works for me:
var client = new SocketClient() { tls = true };
// Or do this (does the same):
// var client = new SocketClient();
// client.tls = true;
var socket = client.connect_to_host (hostname, 443);
If the server you are connecting to are using a self-signed certificate,
you also have to change the TLS validation flags:
client.set_tls_validation_flags (...);
But it's probably easier with Soup, as another commenter pointed out.
God luck. Vala is a sweet language.

Get user followers in meteorjs

I'm trying to get the followers for a user that has authenticated through my meteorjs app. I have used the {{loginButtons}} template and have found where the users tokens are. However I now have to create my authorized request by hand and I was hoping this'd be easy. But it's really hard and I feel like I'm wasting time with trying to figure out a way to create the oauth_signature..
Any help is welcome!
Supposing it is Twitter you're talking about I might be able to help you out.
I just managed to do the same thing as you want to do.
This nice piece of code provides a client to the Twitter API: https://github.com/mynetx/codebird-js
Personally I have placed it in the server-folder in my app to avoid exposure of keys etc.
As the codebird-js code take use of XMLHttpRequests and node.js do not come with such functionality by default - at least in a meteor.js context - you have to add the XHR-functionality yourself.
This NPM did it for me: https://npmjs.org/package/xmlhttprequest
However, as you can not deploy your meteor app with additional npm packages I found this solution How can I deploy node modules in a Meteor app on meteor.com? that suggests placing it in the public folder.
Finally I added those lines of code in the codebird-js just below the line that says
var Codebird = function () {
var require = __meteor_bootstrap__.require;
var path = require('path');
var fs = require('fs');
var base = path.resolve('.');
var isBundle = fs.existsSync(base + '/bundle');
var modulePath = base + (isBundle ? '/bundle/static' : '/public') + '/node_modules';
var XMLHttpRequest = require(modulePath + '/xmlhttprequest').XMLHttpRequest;
Finally you have to provide your tokens generated at dev.twitter.com and find your user's tokens stored in the Users collection.
EDIT:
Whenenver you have the above you make a new Codebird object: var bird = new Codebird();
Then you set tokens:
bird.setToken(USER_ACCESS_TOKEN, USER_ACCESS_TOKEN_SECRET);
And makes the call:
bird.__call('friends/ids', {
screen_name': SCREEN_NAME,
user_id: TWITTER_ID
},
function(reply){
console.log(reply);
});
Note that USER_ACCESS_TOKEN, USER_ACCESS_TOKEN_SECRET, USER_NAME & TWITTER_ID in the above example are placeholders. They are all found in the Meteor Users collection.

Disable Relying Party Discovery

Is it possible to disable Relying Party Discovery on DotNetOpenAuth using some configuration value, or would I need to do it by modifying code? If configuration value, what would it be, if code, what file should I be looking at?
Problem with RP Discovery is that RP in question doesn't support it and it is causing 10 sec delay in authentication when DotNetOpenAuth is trying to query RP until the HTTP GET times out.
Appears that this wasn't configurable in DotNetOpenAuth, but was in fact done (in the sample code) on the Decide.aspx page, so it was possible comment out the lines.
relyingPartyVerificationResultLabel.Text =
ProviderEndpoint.PendingRequest.IsReturnUrlDiscoverable(ProviderEndpoint.Provider.Channel.WebRequestHandler) == RelyingPartyDiscoveryResult.Success ? "passed" : "failed";
realmLabel.Text = ProviderEndpoint.PendingRequest.Realm.ToString();

Resources