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

Commit

Permalink
integrating train 2011.10.06
Browse files Browse the repository at this point in the history
  • Loading branch information
lloyd committed Oct 13, 2011
2 parents 13d9e8a + 85d8db3 commit 20c0f26
Show file tree
Hide file tree
Showing 109 changed files with 6,081 additions and 2,637 deletions.
19 changes: 19 additions & 0 deletions ChangeLog
@@ -1,3 +1,22 @@
train-2011.10.06:
* full site & dialog redesign: (many, many closed issues are related to this, including #269, #343, #342, #347, #354, #356, #357, #350, #349, #364, #346, #336)
* improved debugging, all network callbacks are invoked asynchronously: #276
* MYSQL SCHEMA CHANGE: passwd field no longer in staged table (password is now set after verfiy link clickthrough)
* MYSQL SCHEMA CHANGE: add index to emails table: #209
* WSAPI CHANGES (to support new UI): https://github.com/mozilla/browserid/commit/b6ee51
* WSAPI CHANGES: a mis-set client clock no longer causes invalid assertions to be issued (wsapi changed to minimize network requests): #329
* disallow re-registration of existing account: #333
* (non-visible) namespacing in dialog code: #275
* API BREAKING CHANGE: verifier no longer supports GET requests: #98
* significant performance / UX improvment - keys are generated and certified when needed, not all upfront at sign-in: #278
* remove 'download printable format' language from privacy policy: #280
* faster keygen via crypto optimizations: https://github.com/mozilla/browserid/commit/778433
* improvements to mobile layout & usability (specific to the new UI)
* more user visible error messages to improve community sourced problem reports: #335
* IE8 improvements (still not fully supported): #246, #361, #346
* cookie fixes revisited, now on upstream version of connect-cookie-session: #310
* (merged 2011.10.07) fix unstyled flash at first dialog display: #365

train-2011.09.29:
* shortly after dialog is spawned, we remove the four random chars in the fragment (aesthetic)
* fix bug where session duration had an upper bound of 7 days - the time the server was running: #310
Expand Down
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -42,9 +42,8 @@ Here's the software you'll need installed:

* node.js (>= 0.4.5): http://nodejs.org/
* npm: http://npmjs.org/
* Several node.js 3rd party libraries - see `package.json` for details
* browserify which will be installed globally.
* git, g++
* git
* g++

## Getting started:

Expand Down
35 changes: 21 additions & 14 deletions browserid/app.js
Expand Up @@ -102,34 +102,41 @@ function router(app) {
res.render('index.ejs', {title: 'A Better Way to Sign In', fullpage: true});
});

app.get(/^\/prove(\.html)?$/, function(req,res) {
res.render('prove.ejs', {title: 'Verify Email Address', fullpage: false});
// BA removed .html URLs. If we have 404s,
// we should set up some redirects

app.get("/signup", function(req, res) {
res.render('signup.ejs', {title: 'Sign Up', fullpage: false});
});

app.get(/^\/users(\.html)?$/, function(req,res) {
res.render('users.ejs', {title: 'for Users', fullpage: false});
app.get("/forgot", function(req, res) {
res.render('forgot.ejs', {title: 'Forgot Password', fullpage: false, email: req.query.email});
});

app.get(/^\/developers(\.html)?$/, function(req,res) {
res.render('developers.ejs', {title: 'for Developers', fullpage: false});
app.get("/signin", function(req, res) {
res.render('signin.ejs', {title: 'Sign In', fullpage: false});
});

app.get(/^\/primaries(\.html)?$/, function(req,res) {
res.render('primaries.ejs', {title: 'for Primary Authorities', fullpage: false});
app.get("/about", function(req, res) {
res.render('about.ejs', {title: 'About', fullpage: false});
});

app.get(/^\/manage(\.html)?$/, function(req,res) {
res.render('manage.ejs', {title: 'My Account', fullpage: false});
});

app.get(/^\/tos(\.html)?$/, function(req, res) {
app.get("/tos", function(req, res) {
res.render('tos.ejs', {title: 'Terms of Service', fullpage: false});
});

app.get(/^\/privacy(\.html)?$/, function(req, res) {
app.get("/privacy", function(req, res) {
res.render('privacy.ejs', {title: 'Privacy Policy', fullpage: false});
});

app.get("/verify_email_address", function(req, res) {
res.render('verifyuser.ejs', {title: 'Complete Registration', fullpage: true, token: req.query.token});
});

app.get("/add_email_address", function(req,res) {
res.render('verifyemail.ejs', {title: 'Verify Email Address', fullpage: false});
});

// register all the WSAPI handlers
wsapi.setup(app);

Expand Down
12 changes: 8 additions & 4 deletions browserid/compress.sh
Expand Up @@ -12,7 +12,7 @@ if [ ! -x "$JAVA" ]; then
exit 1
fi

YUI_LOCATION='../../static/steal/build/scripts/yui.jar'
YUI_LOCATION=`pwd`'/static/steal/build/scripts/yui.jar'

echo ''
echo '****Compressing include.js****'
Expand All @@ -32,7 +32,11 @@ cd dialog
$UGLIFY < production.js > production.min.js
mv production.min.js production.js

cd ../relay
cd css
cat popup.css m.css > production.css
$JAVA -jar $YUI_LOCATION production.css -o production.min.css

cd ../../relay
cat ../dialog/resources/jschannel.js relay.js > production.js
$UGLIFY < production.js > production.min.js
mv production.min.js production.js
Expand All @@ -44,9 +48,9 @@ echo ''

cd ../js
# re-minimize everything together
cat jquery-1.6.2.min.js json2.js ../dialog/resources/underscore-min.js ../dialog/resources/storage.js ../dialog/resources/browserid-network.js ../dialog/resources/browserid-identities.js browserid.js > lib.js
cat jquery-1.6.2.min.js json2.js browserid.js ../dialog/resources/underscore-min.js ../dialog/resources/browserid-extensions.js ../dialog/resources/storage.js ../dialog/resources/browserid-network.js ../dialog/resources/browserid-identities.js ../dialog/resources/tooltip.js ../dialog/resources/validation.js pages/index.js pages/add_email_address.js pages/verify_email_address.js pages/manage_account.js pages/signin.js pages/signup.js pages/forgot.js > lib.js
$UGLIFY < lib.js > lib.min.js

cd ../css
cat github.css style.css > browserid.css
cat style.css m.css > browserid.css
$JAVA -jar $YUI_LOCATION browserid.css -o browserid.min.css
1 change: 1 addition & 0 deletions browserid/lib/db.js
Expand Up @@ -99,6 +99,7 @@ exports.onReady = function(f) {
'stageUser',
'stageEmail',
'gotVerificationSecret',
'emailForVerificationSecret',
'checkAuth',
'listEmails',
'removeEmail',
Expand Down
20 changes: 13 additions & 7 deletions browserid/lib/db_json.js
Expand Up @@ -146,17 +146,16 @@ function addEmailToAccount(existing_email, email, cb) {
});
}

exports.stageUser = function(obj, cb) {
exports.stageUser = function(email, cb) {
var secret = secrets.generate(48);

// overwrite previously staged users
staged[secret] = {
type: "add_account",
email: obj.email,
pass: obj.hash
email: email
};

stagedEmails[obj.email] = secret;
stagedEmails[email] = secret;
setTimeout(function() { cb(secret); }, 0);
};

Expand All @@ -172,7 +171,14 @@ exports.stageEmail = function(existing_email, new_email, cb) {
setTimeout(function() { cb(secret); }, 0);
};

exports.gotVerificationSecret = function(secret, cb) {

exports.emailForVerificationSecret = function(secret, cb) {
setTimeout(function() {
cb(staged[secret]? staged[secret].email:undefined);
}, 0);
};

exports.gotVerificationSecret = function(secret, hash, cb) {
if (!staged.hasOwnProperty(secret)) return cb("unknown secret");

// simply move from staged over to the emails "database"
Expand All @@ -183,11 +189,11 @@ exports.gotVerificationSecret = function(secret, cb) {
exports.emailKnown(o.email, function(known) {
function createAccount() {
db.push({
password: o.pass,
password: hash,
emails: [ o.email ]
});
flush();
cb();
cb(undefined, o.email);
}

// if this email address is known and a user has completed a re-verification of this email
Expand Down
39 changes: 25 additions & 14 deletions browserid/lib/db_mysql.js
Expand Up @@ -41,7 +41,7 @@
/*
* The Schema:
*
* +--- user ------+ +--- email ----+
* +--- user ------+ +--- email ----+
* |*int id | <-\ |*int id |
* | string passwd | \- |*int user |
* +---------------+ |*string address
Expand All @@ -53,7 +53,6 @@
* | bool new_acct |
* | string existing |
* |*string email |
* | string passwd |
* | timestamp ts |
* +------------------------+
*/
Expand All @@ -70,8 +69,8 @@ var drop_on_close = undefined;

const schemas = [
"CREATE TABLE IF NOT EXISTS user ( id INTEGER AUTO_INCREMENT PRIMARY KEY, passwd VARCHAR(64) );",
"CREATE TABLE IF NOT EXISTS email ( id INTEGER AUTO_INCREMENT PRIMARY KEY, user INTEGER, address VARCHAR(255) UNIQUE, INDEX(address) );",
"CREATE TABLE IF NOT EXISTS staged ( secret VARCHAR(48) PRIMARY KEY, new_acct BOOL, existing VARCHAR(255), email VARCHAR(255) UNIQUE, INDEX(email), passwd VARCHAR(64), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP);"
"CREATE TABLE IF NOT EXISTS email ( id INTEGER AUTO_INCREMENT PRIMARY KEY, user INTEGER, INDEX(user), address VARCHAR(255) UNIQUE, INDEX(address) );",
"CREATE TABLE IF NOT EXISTS staged ( secret VARCHAR(48) PRIMARY KEY, new_acct BOOL, existing VARCHAR(255), email VARCHAR(255) UNIQUE, INDEX(email), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP);"
];

// log an unexpected database error
Expand Down Expand Up @@ -184,12 +183,12 @@ exports.isStaged = function(email, cb) {
);
}

exports.stageUser = function(obj, cb) {
exports.stageUser = function(email, cb) {
var secret = secrets.generate(48);
// overwrite previously staged users
client.query('INSERT INTO staged (secret, new_acct, email, passwd) VALUES(?,TRUE,?,?) ' +
'ON DUPLICATE KEY UPDATE secret=?, existing="", new_acct=TRUE, passwd=?',
[ secret, obj.email, obj.hash, secret, obj.hash],
client.query('INSERT INTO staged (secret, new_acct, email) VALUES(?,TRUE,?) ' +
'ON DUPLICATE KEY UPDATE secret=?, existing="", new_acct=TRUE',
[ secret, email, secret],
function(err) {
if (err) {
logUnexpectedError(err);
Expand All @@ -198,7 +197,16 @@ exports.stageUser = function(obj, cb) {
});
}

exports.gotVerificationSecret = function(secret, cb) {
exports.emailForVerificationSecret = function(secret, cb) {
client.query(
"SELECT email FROM staged WHERE secret = ?", [ secret ],
function(err, rows) {
if (err) logUnexpectedError(err);
cb((rows && rows.length > 0) ? rows[0].email : undefined);
});
};

exports.gotVerificationSecret = function(secret, hash, cb) {
client.query(
"SELECT * FROM staged WHERE secret = ?", [ secret ],
function(err, rows) {
Expand Down Expand Up @@ -227,7 +235,7 @@ exports.gotVerificationSecret = function(secret, cb) {
[ userID, o.email ],
function(err, info) {
if (err) logUnexpectedError(err);
cb(err ? err : undefined);
cb(err ? err : undefined, o.email);
});
}
});
Expand All @@ -240,7 +248,7 @@ exports.gotVerificationSecret = function(secret, cb) {
// we're creating a new account, add appropriate entries into user and email tables.
client.query(
"INSERT INTO user(passwd) VALUES(?)",
[ o.passwd ],
[ hash ],
function(err, info) {
if (err) { logUnexpectedError(err); cb(err); return; }
addEmailToUser(info.insertId);
Expand Down Expand Up @@ -277,7 +285,7 @@ exports.stageEmail = function(existing_email, new_email, cb) {
var secret = secrets.generate(48);
// overwrite previously staged users
client.query('INSERT INTO staged (secret, new_acct, existing, email) VALUES(?,FALSE,?,?) ' +
'ON DUPLICATE KEY UPDATE secret=?, existing=?, new_acct=FALSE, passwd=""',
'ON DUPLICATE KEY UPDATE secret=?, existing=?, new_acct=FALSE',
[ secret, existing_email, new_email, secret, existing_email],
function(err) {
if (err) {
Expand Down Expand Up @@ -347,8 +355,11 @@ exports.cancelAccount = function(email, cb) {
function (err, rows) {
if (err) {
logUnexpectedError(err)
cb(err);
return
return cb(err);
} else if (!rows || !rows.length === 1 || typeof rows[0] !== 'object') {
var e = "no user with given account: " + email ;
logUnexpectedError(e)
return cb(e);
}
var uid = rows[0].user;
client.query("DELETE LOW_PRIORITY FROM email WHERE user = ?", [ uid ], reportErr);
Expand Down
12 changes: 10 additions & 2 deletions browserid/lib/email.js
Expand Up @@ -61,8 +61,8 @@ exports.setInterceptor = function(callback) {
interceptor = callback;
};

exports.sendVerificationEmail = function(email, site, secret) {
var url = config.get('URL') + "/prove?token=" + encodeURIComponent(secret);
function doSend(landing_page, email, site, secret) {
var url = config.get('URL') + "/" + landing_page + "?token=" + encodeURIComponent(secret);

if (interceptor) {
interceptor(email, site, secret);
Expand All @@ -83,3 +83,11 @@ exports.sendVerificationEmail = function(email, site, secret) {
});
};
};

exports.sendNewUserEmail = function(email, site, secret) {
doSend('verify_email_address', email, site, secret);
};

exports.sendAddAddressEmail = function(email, site, secret) {
doSend('add_email_address', email, site, secret);
};

0 comments on commit 20c0f26

Please sign in to comment.