Skip to content

Commit 49fa97d

Browse files
committed
[java] Logging unauthorized requests when auth info is present
We were logging all attempts, which adds noise to the default logging and is misleading when someone enables it and sees the logs. Fixes SeleniumHQ/docker-selenium#1551
1 parent 95e79d7 commit 49fa97d

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

java/src/org/openqa/selenium/grid/security/BasicAuthenticationFilter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package org.openqa.selenium.grid.security;
1919

20-
import org.openqa.selenium.internal.Debug;
2120
import org.openqa.selenium.internal.Require;
2221
import org.openqa.selenium.remote.http.Filter;
2322
import org.openqa.selenium.remote.http.HttpHandler;
@@ -43,8 +42,11 @@ public HttpHandler apply(HttpHandler next) {
4342
return req -> {
4443
Require.nonNull("Request", req);
4544

46-
if (!isAuthorized(req.getHeader("Authorization"))) {
47-
LOG.log(Debug.getDebugLogLevel(), "Unauthorized request to " + req);
45+
String auth = req.getHeader("Authorization");
46+
if (!isAuthorized(auth)) {
47+
if (auth != null) {
48+
LOG.info("Unauthorized request to " + req);
49+
}
4850
return new HttpResponse()
4951
.setStatus(HttpURLConnection.HTTP_UNAUTHORIZED)
5052
.addHeader("WWW-Authenticate", "Basic realm=\"selenium-server\"");

0 commit comments

Comments
 (0)