This commit is contained in:
thosakwe 2017-03-02 17:37:19 -05:00
parent cad1be1b78
commit cb5c61dc14
3 changed files with 18 additions and 27 deletions

View file

@ -1,5 +1,5 @@
# security
[![version 1.0.0-alpha+1](https://img.shields.io/badge/pub-v1.0.0--alpha+1-red.svg)](https://pub.dartlang.org/packages/angel_security)
[![version 1.0.0](https://img.shields.io/badge/pub-v1.0.0-brightgreen.svg)](https://pub.dartlang.org/packages/angel_security)
[![build status](https://travis-ci.org/angel-dart/security.svg)](https://travis-ci.org/angel-dart/security)
Angel middleware designed to enhance application security by patching common Web security

View file

@ -25,7 +25,9 @@ HookedServiceEventListener hashPassword(
else if (passwordField == 'password')
return user?.password;
else
return reflect(user).getField(new Symbol(passwordField ?? 'password')).reflectee;
return reflect(user)
.getField(new Symbol(passwordField ?? 'password'))
.reflectee;
}
_setPassword(password, user) {
@ -41,35 +43,24 @@ HookedServiceEventListener hashPassword(
}
if (e.data != null) {
var password;
applyHash(user) async {
var password = (await _getPassword(user))?.toString();
if (e.data is Iterable) {
for (var data in e.data) {
var p = await _getPassword(data);
if (p != null) {
password = p;
break;
}
}
} else
password = await _getPassword(e.data);
if (password != null) {
applyHash(user) async {
var password = (await _getPassword(user))?.toString();
if (password != null) {
var digest = h.convert(password.codeUnits);
return _setPassword(new String.fromCharCodes(digest.bytes), user);
}
if (e.data is Iterable) {
var data = await Future.wait(e.data.map(applyHash));
e.data = e.data is List ? data.toList() : data;
} else
e.data = await applyHash(e.data);
// TODO (thosakwe): Add salting capability
}
if (e.data is Iterable) {
var futures = await Future.wait(e.data.map((data) async {
await applyHash(data);
return data;
}));
e.data = futures.toList();
} else
await applyHash(e.data);
}
};
}

View file

@ -1,5 +1,5 @@
name: angel_security
version: 1.0.0-alpha+1
version: 1.0.0
description: Angel middleware designed to enhance application security by patching common Web security holes.
author: Tobe O <thosakwe@gmail.com>
environment: