Skip to content
Snippets Groups Projects
Commit 9b98efc0 authored by Lloyd Hilaiel's avatar Lloyd Hilaiel Committed by Shane Tomlinson
Browse files

implement a more generic mechanism to enable local testing and development of...

implement a more generic mechanism to enable local testing and development of primary support - allow SHIMMED_PRIMARIES to be provided which stuffs a auth url, provisioning url, and public key in our cache
parent 3e660dd5
No related branches found
No related tags found
No related merge requests found
{
"provisioning": "/provision.html",
"authentication": "/sign_in.html",
"public-key": {
"algorithm":"RS",
"n":"12150646309575666544658791157045645163757575303887721078710172478749665834070170928206481109930468203684865378748391106975718718959563139020999088154811587703010353786258781016056954403240590264386124614262627869140351957459406743577995562584260319925426603313709939197457399455483061173844980456364611416651616781677992262613894501858312578942785385470086255995080524454431673067666784338623903663347118104807073332038428581918086381436489000619294471995801952293054002077519255312962379161724622526642212406262043172654176008908362058486885146430345217844546587383034154533029235541666677817563420349484368059586917",
"e":"65537"
}
}
{"algorithm":"RS","n":"12150646309575666544658791157045645163757575303887721078710172478749665834070170928206481109930468203684865378748391106975718718959563139020999088154811587703010353786258781016056954403240590264386124614262627869140351957459406743577995562584260319925426603313709939197457399455483061173844980456364611416651616781677992262613894501858312578942785385470086255995080524454431673067666784338623903663347118104807073332038428581918086381436489000619294471995801952293054002077519255312962379161724622526642212406262043172654176008908362058486885146430345217844546587383034154533029235541666677817563420349484368059586917","e":"65537","d":"4576260781837071842193157180361592071303664055813671962186294570898545886786914704989861806863508349047919986322940288592423594917052916069629682361493727501615950722587629763634798747809443360175819977323411869539211550207829724456958122453992362737374381640787683739122037791776987029525545151661621734244874349529048661411099247940582269058676233440040049437304921327491451073610454313255668312747483229646664526246661039878272676051442941399721167635066787800827207115116788251299159776482379477214028479230999290715576867912303554133701642412629365556930442426107748834086621121121510537980546710422816219192577"}
\ No newline at end of file
{"algorithm":"RS","n":"12150646309575666544658791157045645163757575303887721078710172478749665834070170928206481109930468203684865378748391106975718718959563139020999088154811587703010353786258781016056954403240590264386124614262627869140351957459406743577995562584260319925426603313709939197457399455483061173844980456364611416651616781677992262613894501858312578942785385470086255995080524454431673067666784338623903663347118104807073332038428581918086381436489000619294471995801952293054002077519255312962379161724622526642212406262043172654176008908362058486885146430345217844546587383034154533029235541666677817563420349484368059586917","e":"65537"}
\ No newline at end of file
......@@ -139,3 +139,35 @@ exports.checkSupport = function(domain, cb) {
cacheAndReturn(false);
});
};
// Support "shimmed primaries" for local development. That is an environment variable that is any number of
// CSV values of the form:
// <domain>|<origin>|<path to .well-known/vep>,
// where 'domain' is the domain that we would like to shim. 'origin' is the origin to which traffic should
// be directed, and 'path to .well-known/vep' is a path to the vep file for the domain
//
// defining this env var will pre-seed the cache so local testing can take place. example:
//
// SHIMMED_PRIMARIES=eyedee.me|http://127.0.0.1:10005|example/primary/.well-known/vep
if (process.env['SHIMMED_PRIMARIES']) {
var shims = process.env['SHIMMED_PRIMARIES'].split(',');
shims.forEach(function(shim) {
var a = shim.split('|');
var domain = a[0], origin = a[1], path = a[2];
var body = require('fs').readFileSync(path);
var r = parseWellKnownBody(body, domain);
r.urls.auth = r.urls.auth.replace('https://' + domain, origin);
r.urls.prov = r.urls.prov.replace('https://' + domain, origin);
g_cache[domain] = {
when: new Date(),
status: r.urls,
publicKey: r.publicKey
};
console.log("inserted primary info for '" + domain + "' into cache, pointed at '" + origin + "'");
});
}
......@@ -63,13 +63,11 @@ BrowserID.Provisioning = (function() {
return fail('internal', 'missing required arguments');
}
args.url = args.url.replace('https://eyedee.me', 'http://127.0.0.1:9999');
// extract the expected origin from the provisioning url
// (this may be a different domain than the email domain part, if the
// domain delates authority)
try {
var origin = /^(http:\/\/[^\/]+)\//.exec(args.url)[1];
var origin = /^(https?:\/\/[^\/]+)\//.exec(args.url)[1];
} catch(e) { alert(e); }
if (!origin) {
return fail('internal', 'bad provisioning url, can\'t extract origin');
......
......@@ -35,6 +35,7 @@ var daemonsToRun = {
HOST: HOST
},
browserid: {
SHIMMED_PRIMARIES: "example.domain|http://" + HOST + ":10005|" + path.join(__dirname, "..", "example", "primary", ".well-known", "vep"),
PORT: 10002,
HOST: HOST
}
......
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