Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
switched to handlebar template for passing the server's owasp config …
Browse files Browse the repository at this point in the history
…down to the client.

reverted some of the other changes (regarding the http request).
  • Loading branch information
wansco committed Sep 8, 2016
1 parent d896d07 commit 4ddb059
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
10 changes: 5 additions & 5 deletions config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ module.exports = {
sandbox: false
},
owasp: {
allowPassphrases : true,
maxLength : 128,
minLength : 10,
minPhraseLength : 20,
minOptionalTestsToPass : 4,
allowPassphrases: true,
maxLength: 128,
minLength: 10,
minPhraseLength: 20,
minOptionalTestsToPass: 4
},
mailer: {
from: process.env.MAILER_FROM || 'MAILER_FROM',
Expand Down
7 changes: 7 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ module.exports = {
callbackURL: '/api/auth/paypal/callback',
sandbox: true
},
owasp: {
allowPassphrases: true,
maxLength: 128,
minLength: 10,
minPhraseLength: 20,
minOptionalTestsToPass: 4
},
mailer: {
from: process.env.MAILER_FROM || 'MAILER_FROM',
options: {
Expand Down
8 changes: 5 additions & 3 deletions modules/core/server/controllers/core.server.controller.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
'use strict';

var validator = require('validator');
var validator = require('validator'),
path = require('path'),
config = require(path.resolve('./config/config'));

/**
* Render the main application page
*/
exports.renderIndex = function (req, res) {

var safeUserObject = null;
if (req.user) {
safeUserObject = {
Expand All @@ -24,7 +25,8 @@ exports.renderIndex = function (req, res) {
}

res.render('modules/core/server/views/index', {
user: JSON.stringify(safeUserObject)
user: JSON.stringify(safeUserObject),
owaspcfg: JSON.stringify(config.owasp)
});
};

Expand Down
5 changes: 5 additions & 0 deletions modules/core/server/views/layout.server.view.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@

<!--Application JavaScript Files-->
{{#each jsFiles}}<script type="text/javascript" src="{{this}}"></script>{{/each}}

<!--owasp config sync-->
<script type="text/javascript">
owaspPasswordStrengthTest.configs = {{{ owaspcfg }}};
</script>

{{#if livereload}}
<!--Livereload script rendered -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
.module('users.services')
.factory('PasswordValidator', PasswordValidator);

PasswordValidator.$inject = ['$window', '$http'];
PasswordValidator.$inject = ['$window'];

function PasswordValidator($window, $http) {
function PasswordValidator($window) {
var owaspPasswordStrengthTest = $window.owaspPasswordStrengthTest;

// get the owasp config from the server configuration
$http.get('/password/rules').success(function (response) {
owaspPasswordStrengthTest.configs = response; // same owasp config used on the server
}).error(function (response) {
// well, it should fall back on the default owasp config defined in that package
});

var service = {
getResult: getResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ var path = require('path'),

var smtpTransport = nodemailer.createTransport(config.mailer.options);

/**
* Get the server defined owasp config for the client
*/
exports.getowaspconfig = function (req, res) {
res.json(config.owasp);
};

/**
* Forgot for reset password (forgot POST)
Expand Down
2 changes: 1 addition & 1 deletion modules/users/server/models/user.server.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var mongoose = require('mongoose'),
generatePassword = require('generate-password'),
owasp = require('owasp-password-strength-test');


console.log(config.owasp, "========================================================", path.resolve('./config/config'));
owasp.configs = config.owasp;


Expand Down
4 changes: 0 additions & 4 deletions modules/users/server/routes/auth.server.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,4 @@ module.exports = function (app) {
// Setting the paypal oauth routes
app.route('/api/auth/paypal').get(users.oauthCall('paypal'));
app.route('/api/auth/paypal/callback').get(users.oauthCallback('paypal'));


// get the config settings for the client side owasp
app.route('/password/rules').get(users.getowaspconfig);
};

0 comments on commit 4ddb059

Please sign in to comment.