This repository has been archived by the owner on Feb 20, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #226 from mozilla/issue-216-pin-flow-rebase
Issue 216 pin flow rebase
- Loading branch information
Showing
28 changed files
with
763 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
issue-216-pin-flow | ||
* Branched off issue-178-stateless-account-linking | ||
* Includes several relevant patches from master | ||
train-2013.04.23: | ||
* Branched off of production (train-2013.01.17) | ||
* Not a true train, but a production hotfix Issue #178 | ||
* (hotfix 2013.04.24) Use claimed email, not mismatched for email provider: #203 | ||
|
||
train-2013.01.17: | ||
* First release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# AWS Deployment with awsbox | ||
|
||
Make sure you have persona_secrets. | ||
|
||
./node_modules/.bin/awsbox -h | ||
|
||
## One time step | ||
|
||
$ ssh app@yourvm.personatest.org | ||
$ git clone https://github.com/mozilla/browserid-certifier.git | ||
$ cd browserid-certifier | ||
$ npm install | ||
$ cp config/local.json-dist config/local.json | ||
$ emacs config/local.json | ||
|
||
Change port to `8081`, change `issuer_hostname` to `yourvm.personatest.org` | ||
|
||
$ mkdir var | ||
$ cd var | ||
$ ../node_modules/.bin/generate-keypair | ||
$ CONFIG_FILES=/home/app/browserid-certifier/config/local.json nohup node bin/certifier > var/certifier.log & | ||
|
||
The certifier is now setup. Each time you `git push` the post deploy hook will fixup your public key. | ||
|
||
## Deploying... | ||
|
||
$ git push yourvm HEAD:master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"browserid_server": "https://login.dev.anosrep.org", | ||
"issuer": "issue216pinflow.personatest.org", | ||
"certifier_host": "localhost", | ||
"certifier_port": 8081, | ||
"client_sessions": { | ||
"cookie_name": "session", | ||
"secret": "YOU MUST CHANGE ME", | ||
"duration": 86400000 | ||
}, | ||
"pin_code_sessions": { | ||
"cookie_name": "pincodedb", | ||
"secret": "YOU MUST CHANGE ME AND BE DIFFERENT", | ||
"duration": 600000 | ||
}, | ||
"email_to_console": false, | ||
"env": "development", | ||
"use_https": false, | ||
"domain_info": { | ||
"yahoo.com": { | ||
"strategy": "yahoo", | ||
"providerName": "Yahoo", | ||
"providerURL": "https://mail.yahoo.com" | ||
} | ||
}, | ||
"express_log_format": "tiny", | ||
"supported_languages": ["en-US"], | ||
"var_path": "/home/app/var" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* 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 _ = require('underscore'), | ||
config = require('./configuration.js'), | ||
ejs = require('ejs'), | ||
emailer = require('nodemailer'), | ||
fs = require('fs'), | ||
logger = require('./logging.js').logger, | ||
path = require('path'), | ||
statsd = require('./statsd'), | ||
url = require('url'); | ||
|
||
/* if smtp parameters are configured, use them */ | ||
try { var smtp_params = config.get('smtp'); } catch(e) {} | ||
if (smtp_params && smtp_params.host) { | ||
emailer.SMTP = { | ||
host: smtp_params.host, | ||
port: smtp_params.port | ||
}; | ||
logger.info("delivering email via SMTP host: " + emailer.SMTP.host); | ||
if (smtp_params.user) { | ||
emailer.SMTP.use_authentication = true; | ||
emailer.SMTP.user = smtp_params.user; | ||
emailer.SMTP.pass = smtp_params.pass; | ||
|
||
logger.info("authenticating to email host as " + emailer.SMTP.user); | ||
} | ||
} | ||
|
||
const TEMPLATE_PATH = path.join(__dirname, "..", "views", "email_templates"); | ||
|
||
// The "gettext" function here is only used for static analysis. | ||
// A real, locale-aware gettext function is used when in doSend. | ||
var gettext = function(a) { return a; }; | ||
var templates = { | ||
"pin_verification": { | ||
landing: 'pin_verification', | ||
subject: gettext("Confirm email address for Persona"), | ||
templatePath: path.join(TEMPLATE_PATH, 'pin_verification.ejs') | ||
} | ||
}; | ||
|
||
function withTemplate(email_type, cb) { | ||
if (!templates[email_type]) { | ||
cb(new Error("unknown email type: " + email_type)); | ||
} else if (templates[email_type].render) { | ||
cb(null, templates[email_type].render); | ||
} else { | ||
fs.readFile(templates[email_type].templatePath, function(err, data) { | ||
if (err) { throw err; } | ||
|
||
var render = ejs.compile(data.toString()); | ||
|
||
templates[email_type].render = render; | ||
|
||
cb(null, render); | ||
}); | ||
} | ||
} | ||
|
||
//TODO send in localeContext | ||
function doSend(email_type, email, context, langContext) { | ||
if (!templates[email_type]) { | ||
throw new Error("unknown email type: " + email_type); | ||
} | ||
|
||
if (config.get('email_to_console')) { | ||
console.log("\nVERIFICATION PIN:\n" + context.pin_code + "\n"); | ||
} else { | ||
withTemplate(email_type, function(err, render) { | ||
var templateArgs = _.extend({ | ||
gettext: langContext.gettext, | ||
format: langContext.format | ||
}, context); | ||
|
||
var mailArgs = { | ||
sender: "Persona <no-reply@persona.org>", | ||
to: email, | ||
subject: langContext.gettext(templates[email_type].subject), | ||
text: render(templateArgs) | ||
}; | ||
|
||
emailer.send_mail(mailArgs, function(err, response) { | ||
if (err || !response) { | ||
logger.error("error sending email to: " + email + " - " + err); | ||
statsd.increment('email.' + email_type + '.sent.error'); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
|
||
exports.sendPinVerification = function(email, msgContext, langContext) { | ||
doSend('pin_verification', email, msgContext, langContext); | ||
}; |
Oops, something went wrong.