Updated logging
This commit is contained in:
parent
fdfd859ff2
commit
c4f26ad4ca
4 changed files with 18 additions and 13 deletions
1
TODO.md
1
TODO.md
|
@ -8,6 +8,7 @@
|
|||
* Websocket
|
||||
* Configuration
|
||||
* Validate
|
||||
* ORM
|
||||
* Framework
|
||||
* Add more examples
|
||||
* Improve User Guide
|
||||
|
|
|
@ -73,7 +73,7 @@ class AuthToken {
|
|||
var split = jwt.split('.');
|
||||
|
||||
if (split.length != 3) {
|
||||
_log.severe('Invalid JWT');
|
||||
_log.warning('Invalid JWT');
|
||||
throw AngelHttpException.notAuthenticated(message: 'Invalid JWT.');
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class AuthToken {
|
|||
var split = jwt.split('.');
|
||||
|
||||
if (split.length != 3) {
|
||||
_log.severe('Invalid JWT');
|
||||
_log.warning('Invalid JWT');
|
||||
throw AngelHttpException.notAuthenticated(message: 'Invalid JWT.');
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ class AuthToken {
|
|||
var signature = base64Url.encode(hmac.convert(data.codeUnits).bytes);
|
||||
|
||||
if (signature != split[2]) {
|
||||
_log.severe('JWT payload does not match hashed version');
|
||||
_log.warning('JWT payload does not match hashed version');
|
||||
throw AngelHttpException.notAuthenticated(
|
||||
message: 'JWT payload does not match hashed version.');
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ class AngelAuth<User> {
|
|||
var req = container.make<RequestContext>();
|
||||
var res = container.make<ResponseContext>();
|
||||
if (req == null || res == null) {
|
||||
_log.severe('RequestContext or responseContext is null');
|
||||
_log.warning('RequestContext or responseContext is null');
|
||||
throw AngelHttpException.forbidden();
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ class AngelAuth<User> {
|
|||
if (result != null) {
|
||||
return result;
|
||||
} else {
|
||||
_log.severe('JWT is null');
|
||||
_log.warning('JWT is null');
|
||||
throw AngelHttpException.forbidden();
|
||||
}
|
||||
});
|
||||
|
@ -219,7 +219,7 @@ class AngelAuth<User> {
|
|||
|
||||
if (enforceIp) {
|
||||
if (req.ip != token.ipAddress) {
|
||||
_log.severe('JWT cannot be accessed from this IP address');
|
||||
_log.warning('JWT cannot be accessed from this IP address');
|
||||
throw AngelHttpException.forbidden(
|
||||
message: 'JWT cannot be accessed from this IP address.');
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ class AngelAuth<User> {
|
|||
token.issuedAt.add(Duration(milliseconds: token.lifeSpan.toInt()));
|
||||
|
||||
if (!expiry.isAfter(DateTime.now())) {
|
||||
_log.severe('Expired JWT');
|
||||
_log.warning('Expired JWT');
|
||||
throw AngelHttpException.forbidden(message: 'Expired JWT.');
|
||||
}
|
||||
}
|
||||
|
@ -304,13 +304,13 @@ class AngelAuth<User> {
|
|||
}
|
||||
|
||||
if (jwt == null) {
|
||||
_log.severe('No JWT provided');
|
||||
_log.warning('No JWT provided');
|
||||
throw AngelHttpException.forbidden(message: 'No JWT provided');
|
||||
} else {
|
||||
var token = AuthToken.validate(jwt, _hs256);
|
||||
if (enforceIp) {
|
||||
if (req.ip != token.ipAddress) {
|
||||
_log.severe('WT cannot be accessed from this IP address');
|
||||
_log.warning('WT cannot be accessed from this IP address');
|
||||
throw AngelHttpException.forbidden(
|
||||
message: 'JWT cannot be accessed from this IP address.');
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ class AngelAuth<User> {
|
|||
if (e is AngelHttpException) {
|
||||
rethrow;
|
||||
}
|
||||
_log.severe('Malformed JWT');
|
||||
_log.warning('Malformed JWT');
|
||||
throw AngelHttpException.badRequest(message: 'Malformed JWT');
|
||||
}
|
||||
}
|
||||
|
@ -371,8 +371,11 @@ class AngelAuth<User> {
|
|||
for (var i = 0; i < names.length; i++) {
|
||||
var name = names[i];
|
||||
|
||||
var strategy = strategies[name] ??=
|
||||
throw ArgumentError('No strategy "$name" found.');
|
||||
var strategy = strategies[name];
|
||||
if (strategy == null) {
|
||||
_log.severe('No strategy "$name" found.');
|
||||
throw ArgumentError('No strategy "$name" found.');
|
||||
}
|
||||
|
||||
var reqContainer = req.container;
|
||||
|
||||
|
@ -450,6 +453,7 @@ class AngelAuth<User> {
|
|||
await res.redirect(options.failureRedirect);
|
||||
return false;
|
||||
} else {
|
||||
_log.warning('Not authenticated');
|
||||
throw AngelHttpException.notAuthenticated();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ class LocalAuthStrategy<User> extends AuthStrategy<User> {
|
|||
verificationResult =
|
||||
await verifier(usrPassMatch.group(1), usrPassMatch.group(2));
|
||||
} else {
|
||||
_log.severe('Bad request: $invalidMessage');
|
||||
_log.warning('Bad request: $invalidMessage');
|
||||
throw AngelHttpException.badRequest(errors: [invalidMessage]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue