From cb5c61dc149b02d284bdc1062086a508961de6ae Mon Sep 17 00:00:00 2001 From: thosakwe Date: Thu, 2 Mar 2017 17:37:19 -0500 Subject: [PATCH] 1.0.0 --- README.md | 2 +- lib/src/hooks/hash_password.dart | 41 +++++++++++++------------------- pubspec.yaml | 2 +- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e0c73bad..7901e03e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/src/hooks/hash_password.dart b/lib/src/hooks/hash_password.dart index 6cd7ed3a..f05756c6 100644 --- a/lib/src/hooks/hash_password.dart +++ b/lib/src/hooks/hash_password.dart @@ -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); } }; } diff --git a/pubspec.yaml b/pubspec.yaml index 50678568..ee914fc9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 environment: