diff --git a/CHANGELOG.md b/CHANGELOG.md index 20e2c2f9..3aaa1f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.0.0-alpha.1 +* Make `ServiceRateLimiter` more fail-proof. + # 2.0.0-alpha * Angel 2 updates. Remove previous functionality. * Add `CookieSigner`, `RateLimiter`/`InMemoryRateLimiter`/`ServiceRateLimiter`. \ No newline at end of file diff --git a/lib/src/helmet.dart b/lib/src/helmet.dart new file mode 100644 index 00000000..7cababd9 --- /dev/null +++ b/lib/src/helmet.dart @@ -0,0 +1,5 @@ +import 'package:angel_framework/angel_framework.dart'; + +class Helmet { + +} \ No newline at end of file diff --git a/lib/src/service_rate_limiter.dart b/lib/src/service_rate_limiter.dart index 6b381db4..f3bb1e4f 100644 --- a/lib/src/service_rate_limiter.dart +++ b/lib/src/service_rate_limiter.dart @@ -21,10 +21,20 @@ class ServiceRateLimiter extends RateLimiter { FutureOr> getCurrentWindow( RequestContext req, ResponseContext res, DateTime currentTime) async { var id = await getId(req, res); - var existing = await service.read(id).catchError((_) => null, - test: (e) => e is AngelHttpException && e.statusCode == 404); - if (existing != null) { - return RateLimitingWindow.fromJson(existing); + try { + var data = await service.read(id); + if (data != null) { + return RateLimitingWindow.fromJson(data); + } + } catch (e) { + if (e is AngelHttpException) { + if (e.statusCode == 404) { + } else { + rethrow; + } + } else { + rethrow; + } } var window = RateLimitingWindow(id, currentTime, 0); diff --git a/pubspec.yaml b/pubspec.yaml index 6f9977d7..5211f6aa 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_security -version: 2.0.0-alpha +version: 2.0.0-alpha.1 description: Angel infrastructure for improving security, rate limiting, and more. author: Tobe O homepage: https://github.com/angel-dart/security