Skip to content

Commit

Permalink
fixes #274 update unified security handler to handle the basic and ap…
Browse files Browse the repository at this point in the history
…ikey with a boolean return (#275)
  • Loading branch information
stevehu authored Jan 6, 2023
1 parent 6aface3 commit 3c74968
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,13 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.endExchange();
return;
} else {
handler.handleBasicAuth(exchange, reqPath, authorization);
break;
if(handler.handleBasicAuth(exchange, reqPath, authorization)) {
// verification is passed, go to the next handler in the chain
break;
} else {
// verification is not passed and an error is returned. Don't call the next handler.
return;
}
}
} else if (BEARER_PREFIX.equalsIgnoreCase(authorization.substring(0, 6))) {
Map<String, HttpHandler> handlers = Handler.getHandlers();
Expand All @@ -108,7 +113,7 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
// verification is passed, go to the next handler in the chain.
break;
} else {
// verification is not passed and an error is returned.
// verification is not passed and an error is returned. Don't call the next handler.
return;
}
}
Expand All @@ -130,8 +135,13 @@ public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.endExchange();
return;
} else {
handler.handleApiKey(exchange, reqPath);
break;
if(handler.handleApiKey(exchange, reqPath)) {
// the APIKey handler successfully verified the credentials. Need to break here so that the next handler can be called.
break;
} else {
// verification is not passed and an error is returned. need to bypass the next handler.
return;
}
}

}
Expand Down

0 comments on commit 3c74968

Please sign in to comment.