Fixed Auth failed test cases

This commit is contained in:
thomashii@dukefirehawk.com 2023-06-03 10:29:43 +08:00
parent 1d00088d89
commit 4ebb63c5f7
3 changed files with 10 additions and 1 deletions

View file

@ -12,6 +12,6 @@ Content-Type: application/json
Authorization: Basic password:username Authorization: Basic password:username
### Force basic ### Force basic
POST http://localhost:3000/hello HTTP/1.1 GET http://localhost:3000/hello HTTP/1.1
Content-Type: application/json Content-Type: application/json
Accept:application/json Accept:application/json

View file

@ -71,6 +71,14 @@ class LocalAuthStrategy<User> extends AuthStrategy<User> {
} }
} }
if (verificationResult == null) {
if (forceBasic) {
res.headers['www-authenticate'] = 'Basic realm="$realm"';
return null;
}
return null;
}
if (verificationResult is Map && verificationResult.isEmpty) { if (verificationResult is Map && verificationResult.isEmpty) {
if (localOptions.failureRedirect != null && if (localOptions.failureRedirect != null &&
localOptions.failureRedirect!.isNotEmpty) { localOptions.failureRedirect!.isNotEmpty) {

View file

@ -46,6 +46,7 @@ void main() async {
app = Angel(reflector: MirrorsReflector()); app = Angel(reflector: MirrorsReflector());
angelHttp = AngelHttp(app, useZone: false); angelHttp = AngelHttp(app, useZone: false);
await app.configure(wireAuth); await app.configure(wireAuth);
app.get('/hello', (req, res) { app.get('/hello', (req, res) {
// => 'Woo auth' // => 'Woo auth'
return 'Woo auth'; return 'Woo auth';