Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 76e9522414
Fetching contributors…

Cannot retrieve contributors at this time

executable file 103 lines (93 sloc) 2.964 kB
#!/usr/bin/env node
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const
https = require('https'),
und = require('underscore'),
urlp = require('url'),
util = require('util'),
primary = require('../lib/primary'),
logging = require('../lib/logging.js');
logging.enableConsoleLogging();
if (process.argv.length !== 3) {
console.log('Checks to see if a domain has a proper declaration of support as a browserid primary');
console.log('Usage:', process.argv[1], '<domain>');
process.exit(1);
}
var domain = process.argv[2];
primary.checkSupport(domain, function(err, urls, publicKey) {
if (err || publicKey === null) {
if (err) {
process.stderr.write("error: " + err + "\n");
}
process.exit(1);
}
console.log('Primary domain: ', domain);
console.log('Public Key: ', publicKey);
var authopts = {
xframe: false
};
getResource('auth', urls.auth, urls, authopts, function () {
getResource('prov', urls.prov, urls, {
xframe: true
});
});
});
/**
* Retrieve one of their urls and examine aspects of it for issues
*/
function getResource(mode, url, urls, opts, cb) {
var path = urlp.parse(url).path;
var body = "",
r = https.request({
host: domain,
path: path,
method: 'GET'
}, checkResource(url, opts, body));
r.on('data', function (chunk) {
body += chunk;
});
r.on('error', function (e) {
console.log("ERROR: ", e.message);
});
r.on('close', function () {
var includes = {
'auth': '/authentication_api.js',
'prov': '/provisioning_api.js'
};
if (body.indexOf(util.format("https://login.persona.org%s", includes[mode])) == -1 &&
body.indexOf(util.format("https://login.anosrep.org%s", includes[mode])) == -1 &&
body.indexOf(util.format("https://login.dev.anosrep.org%s", includes[mode])) == -1) {
console.log(util.format("WARNING: No https://persona.org/%s script tag detected", includes[mode]));
}
if (cb) {
cb();
}
});
r.end();
};
/**
* Called once we have a response.
*
* Do the provisioning and signin resources look kosher?
*/
function checkResource (url, opts, body) {
return function (resp) {
// Their are no X-Frame options
if (resp.statusCode != 200) {
console.log("ERROR: HTTP status code=", resp.statusCode, url);
} else {
if (opts.xframe === true) {
var xframe = und.filter(Object.keys(resp.headers), function (header) {
return header.toLowerCase() == 'x-frame-options';
});
if (xframe.length == 1) {
console.log("ERROR: X-Frame-Options=", resp.headers[xframe[0]], ", BrowserID will not be able to communicate with your site." +
" Suppress X-Frame-Options for ", url);
}
}
resp.setEncoding('utf8');
}
};
};
Jump to Line
Something went wrong with that request. Please try again.