Skip to content
Snippets Groups Projects
Commit 57b27945 authored by Austin King's avatar Austin King
Browse files

Adding X-Frame-Options detection and 200 check for auth and provisioning urls

parent 14ac65bb
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const
https = require('https'),
und = require('underscore'),
primary = require('../lib/primary'),
logging = require('../lib/logging.js');
......@@ -15,11 +18,53 @@ if (process.argv.length !== 3) {
console.log('Usage:', process.argv[1], '<domain>');
process.exit(1);
}
var domain = process.argv[2];
primary.checkSupport(process.argv[2], function(err, urls, publicKey) {
primary.checkSupport(domain, function(err, urls, publicKey) {
if (err) {
process.stderr.write("error: " + err + "\n");
process.exit(1);
}
console.log(urls, publicKey);
console.log('Priary domain: ', domain);
console.log('Public Key: ', publicKey);
getResource(urls.auth, urls);
getResource(urls.prov, urls);
});
/**
* Retrieve one of their urls and examine aspects of it for issues
*/
function getResource(url, urls) {
console.log('Checking ', urls.auth);
var r = https.request({
host: domain,
path: url,
method: 'GET'
}, checkResource(urls));
r.on('error', function (e) {
console.log("ERROR: ", e.message);
});
r.end();
};
/**
* Called once we have a response.
*
* Do the provisioning and signin resources look kosher?
*/
function checkResource (urls) {
return function (resp) {
// Their are no X-Frame options
if (resp.statusCode != 200) {
console.log("ERROR: HTTP status code=", resp.statusCode);
} else {
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 /.well-known/browserid, " + urls.auth + ' and ' + urls.prov);
}
}
};
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment