Skip to content

Commit

Permalink
feat(server): run the server over https
Browse files Browse the repository at this point in the history
  • Loading branch information
petebacondarwin committed Mar 12, 2013
1 parent 07c3b3b commit 5d8f8d0
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 15 deletions.
20 changes: 10 additions & 10 deletions client/src/app/admin/users/users-edit.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
<form name="form" novalidate crud-edit="user">
<legend>User</legend>
<gravatar email="user.email" size="200" class="img-polaroid pull-right"></gravatar>
<label>E-mail</label>
<input class="span6" type="email" name="email" ng-model="user.email" required unique-email>
<label for="email">E-mail</label>
<input class="span6" type="email" id="email" name="email" ng-model="user.email" required unique-email>
<span ng-show="showError('email', 'required')" class="help-inline">This field is required.</span>
<span ng-show="showError('email', 'email')" class="help-inline">Please enter a valid email address.</span>
<span ng-show="showError('email', 'uniqueEmail')" class="help-inline">This email address is not available - please enter another.</span>
<label>Last name</label>
<input class="span6" type="text" name="lastName" ng-model="user.lastName" required>
<label for="lastName">Last name</label>
<input class="span6" type="text" id="lastName" name="lastName" ng-model="user.lastName" required>
<span ng-show="showError('lastName', 'required')" class="help-inline">This field is required.</span>
<label>First name</label>
<input class="span6" type="text" name="firstName" ng-model="user.firstName" required>
<label for="firstName">First name</label>
<input class="span6" type="text" id="firstName" name="firstName" ng-model="user.firstName" required>
<span ng-show="showError('firstName', 'required')" class="help-inline">This field is required.</span>
<label>Password</label>
<input class="span6" type="password" name="password" ng-model="user.password" required>
<label for="password">Password</label>
<input class="span6" type="password" id="password" name="password" ng-model="user.password" required>
<span ng-show="showError('password', 'required')" class="help-inline">This field is required.</span>
<span ng-show="showError('passwordRepeat', 'equal')" class="help-inline">Passwords do not match.</span>
<label>Password (repeat)</label>
<input class="span6" type="password" name="passwordRepeat" ng-model="password" required validate-equals="user.password">
<label for="passwordRepeat">Password (repeat)</label>
<input class="span6" type="password" id="passwordRepeat" name="passwordRepeat" ng-model="password" required validate-equals="user.password">
<span ng-show="showError('passwordRepeat', 'required')" class="help-inline">This field is required.</span>
<span ng-show="showError('passwordRepeat', 'equal')" class="help-inline">Passwords do not match.</span>
<label>Admin</label>
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module('app', [
'templates.common']);

angular.module('app').constant('MONGOLAB_CONFIG', {
baseUrl: 'http://localhost:3000/databases/',
baseUrl: '/databases/',
dbName: 'ascrum'
});

Expand Down
2 changes: 1 addition & 1 deletion client/test/config/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ browsers = ['Chrome'];

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun = true;
singleRun = true;
12 changes: 12 additions & 0 deletions server/cert/certificate.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-----BEGIN CERTIFICATE-----
MIIBvTCCASYCCQChvHfdXC0sgTANBgkqhkiG9w0BAQUFADAjMQswCQYDVQQGEwJH
QjEUMBIGA1UEAxMLQW5ndWxhciBBcHAwHhcNMTMwMjE5MjIyMDA5WhcNMTMwMzIx
MjIyMDA5WjAjMQswCQYDVQQGEwJHQjEUMBIGA1UEAxMLQW5ndWxhciBBcHAwgZ8w
DQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALYnzlpRmZz0IC3rjLqrHoqSqENEzf0I
kRH3yqmob9gY5MWrSx1mAoBPSpd3kS53VX2hR0oH0D3XPP9BbsgkgOfTUd1QLLya
dlWuGEV5PtA7oavr5fb1/tyCcVk8gpG51kSwTDX3Wi58Hig5qSfl78d0V79aRLmW
P6hdEdGL8aP5AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAmbcZsZ7GhILYwJZgvZo8
mE226AwzJFqTQxxitnSQIpJE+ZxzWFdW4JRi8K10codfMLuG+182YiXiprpAPGiA
zQsq3c5n8REYF9r5IXYCcWarsdHVtXhkD7pRCKYk6ZAQp59I/jcc/iSSScwIF2GH
nHAfRSnPHJWIwsk6+UUzKgE=
-----END CERTIFICATE-----
10 changes: 10 additions & 0 deletions server/cert/certrequest.csr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----BEGIN CERTIFICATE REQUEST-----
MIIBYjCBzAIBADAjMQswCQYDVQQGEwJHQjEUMBIGA1UEAxMLQW5ndWxhciBBcHAw
gZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALYnzlpRmZz0IC3rjLqrHoqSqENE
zf0IkRH3yqmob9gY5MWrSx1mAoBPSpd3kS53VX2hR0oH0D3XPP9BbsgkgOfTUd1Q
LLyadlWuGEV5PtA7oavr5fb1/tyCcVk8gpG51kSwTDX3Wi58Hig5qSfl78d0V79a
RLmWP6hdEdGL8aP5AgMBAAGgADANBgkqhkiG9w0BAQUFAAOBgQBzYBspv4KStRn4
LIj5Bii0mPUTbJWTq066i/uKDgIiHW/GjoVQ3B0+RNxty2w18eJpVOzQIrwukzYW
mekxo5dtGexD9uUwSfPu9utwS3YT+ur6uL4jwyNfELdys5nHNr6f4oAKTAyUruj1
QGYQJQtK0bo+ncXNSPhjdQrXVQ6Wog==
-----END CERTIFICATE REQUEST-----
15 changes: 15 additions & 0 deletions server/cert/privatekey.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQC2J85aUZmc9CAt64y6qx6KkqhDRM39CJER98qpqG/YGOTFq0sd
ZgKAT0qXd5Eud1V9oUdKB9A91zz/QW7IJIDn01HdUCy8mnZVrhhFeT7QO6Gr6+X2
9f7cgnFZPIKRudZEsEw191oufB4oOakn5e/HdFe/WkS5lj+oXRHRi/Gj+QIDAQAB
AoGBAIO7J9VTe9bxCbCLz1tT0yN9yifTw3BBWMB4xdyKDlBmOFPne8wH8LkgHp6J
frnu3Smcj/Suz99ZICitBlPBamKDS/ahjlTdRwX0jqf2vSGmGFgQw7A+U6k4KZ+H
3/IO27hVANrNQqHZjIjgXSfF/3hkV3w3e2cgR6q6K1jWMPfdAkEA7Ugy68MM5W8M
Cs51z2FyedKJe/Z3Rz6XaI5oju/zY2n/fgLnfX6xnAHsj303aSqKZ825NwJ3yj5r
8VSQFVuQjwJBAMSGWirqPNvnLi3oKsGZFxxaYdEdG7aSpCf5ZqBBc6rgDzMyvC75
qNTGqr7PbbwKkwY4XMVsD4h2FbLyGmW1NvcCQFSvde0K+ilQjr20nftbzh2IdKUX
e86jmioo2Uxae0U56YOxyajSdNU3IpS7nfEcy7TsiXQGn3ZA/QluotXcjiUCQQCq
biVWIEtlHaijsTsbJ+ut8AfydL7q52MrM5O3mOt5ndQwv2gJiQPMevnqfjMZJ0Z3
13tEzsDtxBJvXJxd5fjjAkA/NnLs9DSsQoObKIveiiHWKMGlAF3O1+yS9qYJG9Gs
6hRbpcMFMi/P8fWeSeSmMleVPKU2G9Ow+F2625B6CgOC
-----END RSA PRIVATE KEY-----
1 change: 1 addition & 0 deletions server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
},
server: {
listenPort: 3000, // The port on which the server is to listen (means that the app is at http://localhost:3000 for instance)
securePort: 8433, // The HTTPS port on which the server is to listen (means that the app is at https://localhost:8433 for instance)
distFolder: path.resolve(__dirname, '../client/dist'), // The folder that contains the application files (note that the files are in a different repository) - relative to this file
staticUrl: '/static', // The base url from which we serve static files (such as js, css and images)
cookieSecret: 'angular-app' // The secret for encrypting the cookie
Expand Down
17 changes: 14 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
var fs = require('fs');
var http = require('http');
var https = require('https');
var privateKey = fs.readFileSync('cert/privatekey.pem').toString();
var certificate = fs.readFileSync('cert/certificate.pem').toString();
var credentials = {key: privateKey, cert: certificate};

var express = require('express');
var mongoProxy = require('./lib/mongo-proxy');
var config = require('./config.js');
Expand All @@ -7,6 +14,8 @@ var xsrf = require('./lib/xsrf');
require('express-namespace');

var app = express();
var secureServer = https.createServer(credentials, app);
var server = http.createServer(app);

// Serve up the favicon
app.use(express.favicon(config.server.distFolder + '/favicon.ico'));
Expand Down Expand Up @@ -78,9 +87,11 @@ app.all('/*', function(req, res) {
res.sendfile('index.html', { root: config.server.distFolder });
});

// A standard error handler - it picks up any left over errors and returns a nicely formatted http 500 error
// A standard error handler - it picks up any left over errors and returns a nicely formatted server 500 error
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));

// Start up the server on the port specified in the config
app.listen(config.server.listenPort);
console.log('Angular App Server - listening on port: ' + config.server.listenPort);
server.listen(config.server.listenPort);
console.log('Angular App Server - listening on port: ' + config.server.listenPort);
secureServer.listen(config.server.securePort);
console.log('Angular App Server - listening on secure port: ' + config.server.securePort);

0 comments on commit 5d8f8d0

Please sign in to comment.