Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save proxy user identity in Channel Context after Proxy Authentication #296

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.timeout.IdleStateHandler;
import io.netty.handler.traffic.GlobalTrafficShapingHandler;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import org.apache.commons.codec.binary.Base64;
Expand Down Expand Up @@ -89,6 +90,11 @@ public class ClientToProxyConnection extends ProxyConnection<HttpRequest> {
* Used for case-insensitive comparisons when checking direct proxy request.
*/
private static final Pattern HTTP_SCHEME = Pattern.compile("^http://.*", Pattern.CASE_INSENSITIVE);

/**
* Context attribute key for username
*/
private static final AttributeKey<String> ATTR_USERNAME = AttributeKey.valueOf("username");

/**
* Keep track of all ProxyToServerConnections by host+port.
Expand Down Expand Up @@ -973,6 +979,10 @@ private boolean authenticationRequired(HttpRequest request) {
LOG.debug(authentication);
request.headers().remove(HttpHeaders.Names.PROXY_AUTHORIZATION);
authenticated.set(true);

//Save username for filtering based on user
ctx.attr(ATTR_USERNAME).set(userName);

return false;
}

Expand Down