diff --git a/src/main/java/org/littleshoot/proxy/ProxyAuthenticator.java b/src/main/java/org/littleshoot/proxy/ProxyAuthenticator.java
index df77c687f..bc8779b17 100644
--- a/src/main/java/org/littleshoot/proxy/ProxyAuthenticator.java
+++ b/src/main/java/org/littleshoot/proxy/ProxyAuthenticator.java
@@ -1,5 +1,7 @@
package org.littleshoot.proxy;
+import io.netty.handler.codec.http.HttpRequest;
+
/**
* Interface for objects that can authenticate someone for using our Proxy on
* the basis of a username and password.
@@ -7,7 +9,7 @@
public interface ProxyAuthenticator {
/**
* Authenticates the user using the specified userName and password.
- *
+ *
* @param userName
* The user name.
* @param password
@@ -15,13 +17,13 @@ public interface ProxyAuthenticator {
* @return true if the credentials are acceptable, otherwise
* false.
*/
- boolean authenticate(String userName, String password);
-
+ boolean authenticate(String userName, String password, HttpRequest httpRequest);
+
/**
- * The realm value to be used in the request for proxy authentication
+ * The realm value to be used in the request for proxy authentication
* ("Proxy-Authenticate" header). Returning null will cause the string
* "Restricted Files" to be used by default.
- *
+ *
* @return
*/
String getRealm();
diff --git a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java
index 964858fbf..968161c4a 100644
--- a/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java
+++ b/src/main/java/org/littleshoot/proxy/impl/ClientToProxyConnection.java
@@ -990,7 +990,7 @@ private boolean authenticationRequired(HttpRequest request) {
String userName = StringUtils.substringBefore(decodedString, ":");
String password = StringUtils.substringAfter(decodedString, ":");
- if (!authenticator.authenticate(userName, password)) {
+ if (!authenticator.authenticate(userName, password, request)) {
writeAuthenticationRequired(authenticator.getRealm());
return true;
}
diff --git a/src/test/java/org/littleshoot/proxy/UsernamePasswordAuthenticatingProxyTest.java b/src/test/java/org/littleshoot/proxy/UsernamePasswordAuthenticatingProxyTest.java
index f3c704aeb..2918d7f68 100644
--- a/src/test/java/org/littleshoot/proxy/UsernamePasswordAuthenticatingProxyTest.java
+++ b/src/test/java/org/littleshoot/proxy/UsernamePasswordAuthenticatingProxyTest.java
@@ -1,5 +1,7 @@
package org.littleshoot.proxy;
+import io.netty.handler.codec.http.HttpRequest;
+
/**
* Tests a single proxy that requires username/password authentication.
*/
@@ -24,7 +26,7 @@ protected String getPassword() {
}
@Override
- public boolean authenticate(String userName, String password) {
+ public boolean authenticate(String userName, String password, HttpRequest httpRequest) {
return getUsername().equals(userName) && getPassword().equals(password);
}