Package org.microproxy
Interface ProxyAuthenticator
- All Known Implementing Classes:
ScriptedProxy
public interface ProxyAuthenticator
Decides which clients may use the proxy. By default it validates
Proxy-Authorization:
Basic credentials with authenticate(String, String); override authenticate(HttpRequest, FlowContext) for other schemes (Bearer tokens, API keys, ...) or
other answers.
Whatever the scheme, the proxy removes Proxy-Authorization from every request before
filters see it, so credentials are never forwarded.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanauthenticate(String userName, String password) Validates Basic credentials (for the defaultauthenticate(HttpRequest, FlowContext)).default AuthResultauthenticate(HttpRequest request, FlowContext flow) Decides whetherrequestmay proceed, and as which user.default booleanWhether to authenticate every request rather than the first one accepted on each client connection, e.g. because tokens expire.default StringgetRealm()Returns the realm advertised in the defaultProxy-Authenticate;nullfor the default.
-
Method Details
-
authenticate
Validates Basic credentials (for the defaultauthenticate(HttpRequest, FlowContext)).- Parameters:
userName- the authenticated user name, ornullif unknownpassword- the client password- Returns:
- whether the credentials are accepted
-
getRealm
Returns the realm advertised in the defaultProxy-Authenticate;nullfor the default.- Returns:
- the realm advertised in the default
Proxy-Authenticate;nullfor the default
-
authenticate
Decides whetherrequestmay proceed, and as which user. It sees the requests a client sends to the proxy: plain requests and CONNECTs, not the requests inside an intercepted session (they carry no proxy credentials; the session's CONNECT was authenticated). UnlessauthenticateEveryRequest(), only until one is accepted on each client connection.The accepted user name becomes
ClientDetails.getUserName(), which filters, trackers and theChainedProxyManagersee. It runs on the client connection's thread and may block, e.g. to ask an identity service.The default reads
Proxy-Authorization: Basic: it accepts the user whenauthenticate(String, String)agrees, and rejects with the default challenge otherwise (without asking when the credentials are missing or malformed).- Parameters:
request- the request being handledflow- the client connection, with its address and TLS session- Returns:
AuthResult.accept(java.lang.String), orAuthResult.reject()with the answer to send
-
authenticateEveryRequest
default boolean authenticateEveryRequest()Whether to authenticate every request rather than the first one accepted on each client connection, e.g. because tokens expire. Requests inside an intercepted session are still covered by their CONNECT. Off by default.- Returns:
- whether to authenticate every request rather than the first one accepted on each client connection, e.g. because tokens expire
-