Skip to content

Commit

Permalink
Warn of unauthenticated requests
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jun 8, 2021
1 parent 39b35f8 commit 2c43771
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

import java.net.HttpURLConnection;
import java.util.Base64;
import java.util.logging.Logger;

import static java.nio.charset.StandardCharsets.UTF_8;

public class BasicAuthenticationFilter implements Filter {

private static final Base64.Decoder DECODER = Base64.getDecoder();
private static final Logger LOG = Logger.getLogger(BasicAuthenticationFilter.class.getName());
private final String passphrase;

public BasicAuthenticationFilter(String user, String password) {
Expand All @@ -42,6 +43,7 @@ public HttpHandler apply(HttpHandler next) {
Require.nonNull("Request", req);

if (!isAuthorized(req.getHeader("Authorization"))) {
LOG.info("Unauthorized request to " + req);
return new HttpResponse()
.setStatus(HttpURLConnection.HTTP_UNAUTHORIZED)
.addHeader("WWW-Authenticate", "Basic realm=\"selenium-server\"");
Expand Down

0 comments on commit 2c43771

Please sign in to comment.