さて、ユーザーをサインインさせるために browserID から返されたアサーションを検証しようとしています。browserid-verifier
そうするために、私はパッケージを使用しようとしていました。ただし、インストールできませんでした。node-bigint
以下に示すように、パッケージにエラーがあります。
npm http GET https://registry.npmjs.org/browserid-verifier
npm http 304 https://registry.npmjs.org/browserid-verifier
npm http GET https://registry.npmjs.org/jwcrypto/0.1.1
npm http GET https://registry.npmjs.org/express/2.5.1
npm http 304 https://registry.npmjs.org/jwcrypto/0.1.1
npm http 304 https://registry.npmjs.org/express/2.5.1
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/connect
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/mkdirp/0.0.7
npm http GET https://registry.npmjs.org/browserify/1.8.1
npm http GET https://registry.npmjs.org/vows/0.5.13
npm http GET https://registry.npmjs.org/optimist/0.2.6
npm http GET https://github.com/benadida/node-bigint/tarball/2ac68
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/qs
npm http 304 https://registry.npmjs.org/mkdirp/0.0.7
npm http 304 https://registry.npmjs.org/connect
npm http 304 https://registry.npmjs.org/browserify/1.8.1
npm http 304 https://registry.npmjs.org/vows/0.5.13
npm http GET https://registry.npmjs.org/formidable
npm http 304 https://registry.npmjs.org/optimist/0.2.6
npm http 200 https://github.com/benadida/node-bigint/tarball/2ac68
> bigint@0.3.7 install /home/aaditmshah/struggleforlife/node_modules/browserid-verifier/node_modules/jwcrypto/node_modules/bigint
> node-waf configure build
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/eyes
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr
'configure' finished successfully (0.022s)
Waf: Entering directory `/home/aaditmshah/struggleforlife/node_modules/browserid-verifier/node_modules/jwcrypto/node_modules/bigint/build'
[1/2] cxx: bigint.cc -> build/Release/bigint_1.o
npm http GET https://registry.npmjs.org/detective
npm http GET https://registry.npmjs.org/deputy
npm http GET https://registry.npmjs.org/resolve
npm http GET https://registry.npmjs.org/nub
npm http GET https://registry.npmjs.org/commondir
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/formidable
../bigint.cc:9:17: fatal error: gmp.h: No such file or directory
compilation terminated.
Waf: Leaving directory `/home/aaditmshah/struggleforlife/node_modules/browserid-verifier/node_modules/jwcrypto/node_modules/bigint/build'
Build failed: -> task failed (err #1):
{task: cxx bigint.cc -> bigint_1.o}
npm ERR! error installing bigint@0.3.7
npm ERR! error installing jwcrypto@0.1.1
npm ERR! error installing browserid-verifier@0.0.4
npm ERR! bigint@0.3.7 install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 1
npm ERR!
npm ERR! Failed at the bigint@0.3.7 install script.
npm ERR! This is most likely a problem with the bigint package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls bigint
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Linux 3.0.0-17-generic
npm ERR! command "node" "/usr/bin/npm" "install" "browserid-verifier"
npm ERR! cwd /home/aaditmshah/struggleforlife
npm ERR! node -v v0.6.14
npm ERR! npm -v 1.1.4
npm ERR! code ELIFECYCLE
npm ERR! message bigint@0.3.7 install: `node-waf configure build`
npm ERR! message `sh "-c" "node-waf configure build"` failed with 1
npm ERR! errno {}
npm http 304 https://registry.npmjs.org/resolve
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/aaditmshah/struggleforlife/npm-debug.log
npm not ok
代わりに、アサーションを検証するために独自のコードを作成してみました。これは私が思いついたものです:
var mongoLife = "mongodb://nodejitsu:02a0f2d1cacb5259588ddfdfad59cf49@staff.mongohq.com:10088/nodejitsudb449201704656";
var querystring = require("querystring");
var mongoose = require("mongoose");
var express = require("express");
var https = require("https");
var nowjs = require("now");
mongoose.connect(mongoLife);
var app = express.createServer();
app.use(express.static(__dirname + "/public"));
var everyone = nowjs.initialize(app);
everyone.now.login = function (assertion) {
var client = this.now;
var postData = querystring.stringify({
audience: "http://life.nodejitsu.com/",
assertion: assertion
});
var options = {
host: "browserid.org",
path: "/verify",
method: "POST",
port: 80,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": postData.length
}
};
var request = https.request(options, function (response) {
response.setEncoding("utf8");
response.on("data", function (responseText) {
var user = JSON.parse(responseText);
client.loggedIn(user.status === "okay" ? user.email : null);
});
});
request.write(postData);
request.end();
};
var Schema = mongoose.Schema;
var ObjectId = Schema.ObjectId;
app.listen(8080);
ただし、ユーザーがサインインしようとすると、次のエラーが表示されます。
[Error: 139723080664896:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:683:]
Error: 139723080664896:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:683:
at CleartextStream._puller (tls.js:501:24)
at CleartextStream._pull (tls.js:432:19)
at SecurePair.cycle (tls.js:727:20)
at EncryptedStream.write (tls.js:130:13)
at Socket.ondata (stream.js:38:26)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:367:14)
{ [Error: socket hang up] code: 'ECONNRESET' }
Error: socket hang up
at createHangUpError (http.js:1107:15)
at CleartextStream.<anonymous> (http.js:1210:27)
at CleartextStream.emit (events.js:88:20)
at Array.0 (tls.js:792:22)
at EventEmitter._tickCallback (node.js:192:40)
どんな助けでも大歓迎です。私がやろうとしているのは、への HTTP POST リクエストを作成しhttps://browserid.org/
、アサーションとオーディエンスを渡し、リターン ステータスを確認することだけです。どこが間違っているのか正確に知りたいです。