Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
Change browserid.org urls to persona.org, introduce static.login.pers…
Browse files Browse the repository at this point in the history
…ona.org for all static resources.
  • Loading branch information
lloyd committed Jun 13, 2012
1 parent 46f0e88 commit 96b20bd
Show file tree
Hide file tree
Showing 30 changed files with 100 additions and 72 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -5,15 +5,15 @@
Here lives the [BrowserID][] implementation. BrowserID is an implementation of the
[verified email protocol][VEP].

[BrowserID]:https://browserid.org
[BrowserID]:https://login.persona.org
[VEP]:https://wiki.mozilla.org/Labs/Identity/VerifiedEmailProtocol

This repository contains several distinct things related to BrowserID:

* **the browserid server** - a node.js server which implements a web services api, stores a record of users, the email addresses they've verified, a bcrypted password, outstanding verification tokens, etc
* **the verifier** - a stateless node.js server which does cryptographic verification of assertions. This thing is hosted on browserid.org as a convenience, but people using browserid can choose to host their own version if they wish to.
* **the verifier** - a stateless node.js server which does cryptographic verification of assertions. This thing is hosted on login.persona.org as a convenience, but people using browserid can choose to host their own version if they wish to.
* **sample and test code** - to test the above
* **the browserid.org website** - the templates, css, and javascript that make up the visible part of browserid.org
* **the login.persona.org website** - the templates, css, and javascript that make up the visible part of login.persona.org
* **the javascript/HTML dialog & include library** - this is include.js and the code that it includes, the bit that someone using browserid will include.

## Dependencies
Expand Down
7 changes: 3 additions & 4 deletions bin/browserid
Expand Up @@ -105,13 +105,12 @@ app.use(cachify.setup(assets(config.get('supported_languages')),
{
prefix: config.get('cachify_prefix'),
production: config.get('use_minified_resources'),
root: static_root,
root: static_root
}));


// #7 - perform response substitution to support local/dev/beta environments
// (specifically, this replaces URLs in responses, e.g. https://browserid.org
// with https://diresworb.org)
// (specifically, this replaces URLs in responses, e.g. https://login.persona.org
// with https://login.anosrep.org)
config.performSubstitution(app);

// #8 - handle /wsapi requests
Expand Down
14 changes: 7 additions & 7 deletions docs/DEPLOYMENT.md
Expand Up @@ -9,19 +9,19 @@ Reader beware.
# How to deploy BrowserID

This describes how to take the code here, put it on a server, and build
a service like browserid.org.
a service like persona.org.

So what are we deploying, anyway?

* *the browserid server* - a node.js server which implements a web services
api, stores a record of users, the email addresses they've verified, a
bcrypted password, outstanding verification tokens, etc.
* *the verifier* - a stateless node.js server which does cryptographic
verification of assertions. This thing is hosted on browserid.org as a
verification of assertions. This thing is hosted on persona.org as a
convenience, but people using browserid can choose to relocated it if they
want to their own servers.
* *the browserid.org website* - the templates, css, and javascript that make
up the visible part of browserid.org
* *the persona.org website* - the templates, css, and javascript that make
up the visible part of persona.org
* *the javascript/HTML dialog & include library* - this is include.js and the
code that it includes, the bit that someone using browserid will include.

Expand Down Expand Up @@ -216,7 +216,7 @@ check host verifier with address 127.0.0.1
5. create a file to run the browserid server at `/etc/monit.d/browserid`:

<pre>
check host browserid.org with address 127.0.0.1
check host persona.org with address 127.0.0.1
start program = "/etc/monit/start_node_server /home/browserid/code/browserid/run.js"
as uid "www-data" and gid "www-data"
stop program = "/usr/bin/pkill -f '/usr/local/bin/node /home/browserid/code/browserid/run.js'"
Expand Down Expand Up @@ -276,7 +276,7 @@ http {
<pre>
server {
listen 80 default;
server_name browserid.org;
server_name persona.org;

# pass /verify invocations to the verifier
location /verify {
Expand All @@ -294,7 +294,7 @@ server {

5. restart your webserver: `sudo /etc/init.d/nginx restart`

confirm that it's accepting requests: `curl -I -H 'Host: browserid.org' http://localhost:80/`
confirm that it's accepting requests: `curl -I -H 'Host: persona.org' http://localhost:80/`

### 8. Set up log rotation

Expand Down
4 changes: 2 additions & 2 deletions docs/PRIMARY_PROTOCOL.md
Expand Up @@ -166,7 +166,7 @@ properties available to normal web content.
To support browsers without native BrowserID support, the provisioning
content should include a javascript shim, hosted at:

https://browserid.org/provisioning_api.js
https://login.persona.org/provisioning_api.js

### 4.3. BrowserID API

Expand Down Expand Up @@ -269,7 +269,7 @@ user has successfully authenticated with the primary.
To support browsers without native BrowserID support, the
authentication page should include a javascript shim, hosted at:

https://browserid.org/authentication_api.js
https://login.persona.org/authentication_api.js

### 5.3 BrowserID API

Expand Down
2 changes: 1 addition & 1 deletion example/primary/provision.html
Expand Up @@ -5,7 +5,7 @@

<html>
<head>
<script type="text/javascript" src="https://browserid.org/provisioning_api.js"></script>
<script type="text/javascript" src="https://static.login.persona.org/provisioning_api.js"></script>
<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion example/rp/index.html
Expand Up @@ -110,7 +110,7 @@ <h2>readiness</h2>
</body>

<script src="jquery-min.js"></script>
<script src="https://browserid.org/include.js"></script>
<script src="https://login.persona.org/include.js"></script>
<script>

try {
Expand Down
6 changes: 3 additions & 3 deletions lib/browserid/views.js
Expand Up @@ -165,7 +165,7 @@ exports.setup = function(app) {
});

// serve up testing templates. but NOT in staging or production. see GH-1044
if ([ 'https://browserid.org', 'https://diresworb.org' ].indexOf(config.get('public_url')) === -1) {
if ([ 'https://login.persona.org', 'https://login.anosrep.org' ].indexOf(config.get('public_url')) === -1) {
// serve test.ejs to /test or /test/ or /test/index.html
app.get(/^\/test\/(?:index.html)?$/, function (req, res) {
res.render('test.ejs', {title: 'BrowserID QUnit Test', layout: false});
Expand Down Expand Up @@ -210,11 +210,11 @@ exports.setup = function(app) {
});

// the "declaration of support" style publishing of the public key.
// BrowserID.org is a (uh, THE) secondary, it should publish its key
// login.persona.org is a (uh, THE) secondary, it should publish its key
// in a manner that is symmetric with how primaries do. At present,
// the absence of 'provisioning' and 'authentication' keys indicates
// that this is a secondary, and verifiers should only trust
// browserid.org as a secondary (and anyone else they decide to for
// login.persona.org as a secondary (and anyone else they decide to for
// whatever reason).
app.get("/.well-known/browserid", function(req, res) {
res.json({ 'public-key': publicKey.toSimpleObject() });
Expand Down
42 changes: 36 additions & 6 deletions lib/configuration.js
Expand Up @@ -59,8 +59,18 @@ var conf = module.exports = convict({
},
public_url: {
doc: "The publically visible URL of the deployment",
format: 'string = "https://browserid.org"',
env: 'URL'
format: 'string = "https://login.persona.org"',
env: 'PUBLIC_URL'
},
public_static_url: {
doc: "The publically visible URL from which static resources are served",
format: 'string',
env: 'PUBLIC_STATIC_URL'
},
public_verifier_url: {
doc: "The publically visible URL where incoming verification requests are handled",
format: 'string',
env: 'PUBLIC_VERIFIER_URL'
},
scheme: {
// XXX should we deprecate scheme as it's redundant and derived from 'public_url' ?
Expand Down Expand Up @@ -265,6 +275,19 @@ if (conf.get('env') === 'test_json') {
conf.set('database.driver', 'mysql');
}

// if static and verifier urls are not explicitly set, default them to the
// same as the public url (used in ephemeral and local deployments)
if (!conf.has('public_static_url')) {
conf.set('public_static_url', conf.get('public_url'));
}
if (!conf.has('public_verifier_url')) {
conf.set('public_verifier_url', conf.get('public_url'));
}

// augment the cachify prefix with the public_static_url
var prefix = urlparse(conf.get('public_static_url') + "/" + conf.get('cachify_prefix'));
conf.set('cachify_prefix', prefix.normalize().toString());

// validate the configuration based on the above specification
conf.validate();

Expand All @@ -274,18 +297,25 @@ conf.validate();
*
* Note, for a 'local' environment, no re-write is needed because this is
* handled at a higher level. For other environments, only perform re-writing
* if the host, port, or scheme are different than https://browserid.org:443
* if the host, port, or scheme are different than https://login.persona.org:443
* (all source files always should have the production hostname written into them)
*/
module.exports.performSubstitution = function(app) {
if (conf.get('public_url') != 'https://browserid.org') {
if (conf.get('public_url') != 'https://login.persona.org' ||
conf.get('public_static_url') != 'https://static.login.persona.org' ||
conf.get('public_verifier_url') != 'https://verifier.login.persona.org')
{
app.use(postprocess(function(req, buffer) {
return buffer.toString().replace(new RegExp('https://browserid.org', 'g'), conf.get('public_url'));
return buffer.toString()
.replace(new RegExp('https://login.persona.org', 'g'), conf.get('public_url'))
.replace(new RegExp('https://static.login.persona.org', 'g'), conf.get('public_static_url'))
.replace(new RegExp('https://verifier.login.persona.org', 'g'), conf.get('public_verifier_url'));
}));
}
};

// log the process_type
process.nextTick(function() {
require("./logging.js").logger.info("process type is " + conf.get("process_type"));
var logging = require("./logging.js").logger;
logging.info("process type is " + conf.get("process_type"));
});
4 changes: 2 additions & 2 deletions lib/email.js
Expand Up @@ -60,9 +60,9 @@ function doSend(landing_page, email, site, secret, langContext) {
console.log("\nVERIFICATION URL:\n" + url + "\n");
} else {
// TODO(aok) extract_po.sh isn't seeing this string if it's below in object literal
var subject = format(_("Complete Login to %s using BrowserID"), [site]);
var subject = format(_("Complete Login to %s using Persona"), [site]);
emailer.send_mail({
sender: "BrowserID@browserid.org",
sender: "Persona@persona.org",
to: email,
subject: subject,
body: template({ link: url, site: site, gettext: _, format: format })
Expand Down
4 changes: 2 additions & 2 deletions lib/wsapi.js
Expand Up @@ -42,8 +42,8 @@ const COOKIE_SECRET = secrets.hydrateSecret('browserid_cookie', config.get('var_
var COOKIE_KEY = 'browserid_state';

// to support testing of browserid, we'll add a hash fragment to the cookie name for
// sites other than browserid.org. This is to address a bug in IE, see issue #296
if (config.get('public_url').indexOf('https://browserid.org') !== 0) {
// sites other than login.persona.org. This is to address a bug in IE, see issue #296
if (config.get('public_url').indexOf('https://login.persona.org') !== 0) {
const crypto = require('crypto');
var hash = crypto.createHash('md5');
hash.update(config.get('public_url'));
Expand Down
4 changes: 2 additions & 2 deletions resources/static/include_js/include.js
@@ -1,5 +1,5 @@
/**
* Uncompressed source can be found at https://browserid.org/include.orig.js
* Uncompressed source can be found at https://login.persona.org/include.orig.js
*
* 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
Expand Down Expand Up @@ -924,7 +924,7 @@
}

if (!navigator.id.request || navigator.id._shimmed) {
var ipServer = "https://browserid.org";
var ipServer = "https://login.persona.org";
var userAgent = navigator.userAgent;
// We must check for both XUL and Java versions of Fennec. Both have
// distinct UA strings.
Expand Down
6 changes: 3 additions & 3 deletions resources/static/pages/page_helpers.js
Expand Up @@ -138,13 +138,13 @@ BrowserID.PageHelpers = (function() {

var url = helpers.toURL(baseURL, {
email: email,
return_to: "https://browserid.org/authenticate_with_primary#complete"
return_to: "https://login.persona.org/authenticate_with_primary#complete"
});

winchan.open({
url: "https://browserid.org/authenticate_with_primary",
url: "https://login.persona.org/authenticate_with_primary",
// This is the relay that will be used when the IdP redirects to sign_in_complete
relay_url: "https://browserid.org/relay",
relay_url: "https://login.persona.org/relay",
window_features: "width=700,height=375",
params: url
}, function(error, result) {
Expand Down
2 changes: 1 addition & 1 deletion resources/static/provisioning_api.js
Expand Up @@ -626,7 +626,7 @@
}

if (!navigator.id.beginProvisioning || navigator.id._primaryAPIIsShimmed) {
var ipServer = "https://browserid.org";
var ipServer = "https://login.persona.org";

var chan = Channel.build({window: window.parent, origin: ipServer, scope: "vep_prov"});

Expand Down
14 changes: 7 additions & 7 deletions resources/static/shared/user.js
Expand Up @@ -329,8 +329,8 @@ BrowserID.User = (function() {

/**
* A full provision a primary user, if they are authenticated, save their
* cert/keypair. Note, we do not authenticate to browserid.org but
* merely get an assertion for browserid.org so that we can either add the
* cert/keypair. Note, we do not authenticate to login.persona.org but
* merely get an assertion for login.persona.org so that we can either add the
* email to the current account or authenticate the user if not
* authenticated.
* @method provisionPrimaryUser
Expand All @@ -349,8 +349,8 @@ BrowserID.User = (function() {
if(authInfo.authenticated) {
persistEmailKeypair(email, "primary", authInfo.keypair, authInfo.cert,
function() {
// We are getting an assertion for browserid.org.
User.getAssertion(email, "https://browserid.org", function(assertion) {
// We are getting an assertion for persona.org.
User.getAssertion(email, "https://login.persona.org", function(assertion) {
if (assertion) {
onComplete("primary.verified", {
assertion: assertion
Expand Down Expand Up @@ -621,7 +621,7 @@ BrowserID.User = (function() {
},

/**
* Sync local identities with browserid.org. Generally should not need to
* Sync local identities with login.persona.org. Generally should not need to
* be called.
* @method syncEmails
* @param {function} [onComplete] - Called whenever complete.
Expand Down Expand Up @@ -1186,8 +1186,8 @@ BrowserID.User = (function() {

// Set origin to default to the current domain. Other contexts that use user.js,
// like dialogs or iframes, will call setOrigin themselves to update this to
// the origin of the of the RP. On browserid.org, it will remain the origin of
// browserid.org
// the origin of the of the RP. On login.persona.org, it will remain the origin of
// login.persona.org
var currentOrigin = window.location.protocol + '//' + window.location.hostname;
if (window.location.port) {
currentOrigin += ':' + window.location.port;
Expand Down
4 changes: 2 additions & 2 deletions resources/static/test/cases/pages/verify_secondary_address.js
Expand Up @@ -67,12 +67,12 @@
});

asyncTest("no password: start with good token and site", function() {
storage.setStagedOnBehalfOf("browserid.org");
storage.setStagedOnBehalfOf("persona.org");

createController(config, function() {
testEmail();
ok($(".siteinfo").is(":visible"), "siteinfo is visible when we say what it is");
equal($(".website:nth(0)").text(), "browserid.org", "origin is updated");
equal($(".website:nth(0)").text(), "persona.org", "origin is updated");
testHasClass("body", "complete");
start();
});
Expand Down
2 changes: 1 addition & 1 deletion resources/static/test/cases/resources/internal_api.js
Expand Up @@ -11,7 +11,7 @@
network = bid.Network,
user = bid.User,
xhr = bid.Mocks.xhr,
origin = "https://browserid.org",
origin = "https://login.persona.org",
storage = bid.Storage,
moduleManager = bid.module,
testHelpers = bid.TestHelpers;
Expand Down
8 changes: 4 additions & 4 deletions resources/static/test/cases/shared/helpers.js
Expand Up @@ -90,18 +90,18 @@
});

test("toURL with no GET parameters", function() {
var url = helpers.toURL("https://browserid.org");
var url = helpers.toURL("https://login.persona.org");

equal(url, "https://browserid.org", "correct URL without GET parameters");
equal(url, "https://login.persona.org", "correct URL without GET parameters");
});

test("toURL with GET parameters", function() {
var url = helpers.toURL("https://browserid.org", {
var url = helpers.toURL("https://login.persona.org", {
email: "testuser@testuser.com",
status: "complete"
});

equal(url, "https://browserid.org?email=testuser%40testuser.com&status=complete", "correct URL with GET parameters");
equal(url, "https://login.persona.org?email=testuser%40testuser.com&status=complete", "correct URL with GET parameters");
});

test("whitelistFilter an object", function() {
Expand Down

0 comments on commit 96b20bd

Please sign in to comment.