Class UsersLoadBalancer
- java.lang.Object
-
- jetbrains.buildServer.controllers.interceptors.proxy.UsersLoadBalancer
-
public class UsersLoadBalancer extends Object
This load balancer allows to assign a user to a specific node with help of a special cookiejetbrains.buildServer.xmlrpc.XmlRpcConstants#NODE_ID_COOKIE
. This cookie should also be supported on the HTTP proxy side.- Since:
- 2022.10
-
-
Field Summary
Fields Modifier and Type Field Description static String
GROUP_KEYS_PROP
static String
NODE_ID_PARAM
static String
PROPERTY_USERS_ROUTING_ENABLED
-
Constructor Summary
Constructors Constructor Description UsersLoadBalancer(TeamCityNodes teamCityNodes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
assignAuthenticatedUserToNode(SUser user, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Tries to assign further requests from a user to some other node, by setting a cookie.String
assignUnauthenticatedRequestToNode(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
static boolean
isEnabled(javax.servlet.http.HttpServletRequest request)
static void
sendRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String nodeId)
Sends redirect to the same URL the initial request came from.static boolean
shouldRedirect(javax.servlet.http.HttpServletRequest request, String nodeId)
Checks whether redirect to the initial request's URL is required
-
-
-
Field Detail
-
PROPERTY_USERS_ROUTING_ENABLED
public static final String PROPERTY_USERS_ROUTING_ENABLED
- See Also:
- Constant Field Values
-
GROUP_KEYS_PROP
public static final String GROUP_KEYS_PROP
- See Also:
- Constant Field Values
-
NODE_ID_PARAM
public static final String NODE_ID_PARAM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UsersLoadBalancer
public UsersLoadBalancer(@NotNull TeamCityNodes teamCityNodes)
-
-
Method Detail
-
assignUnauthenticatedRequestToNode
public String assignUnauthenticatedRequestToNode(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response)
-
assignAuthenticatedUserToNode
@Nullable public String assignAuthenticatedUserToNode(@NotNull SUser user, @NotNull javax.servlet.http.HttpServletRequest request, @Nullable javax.servlet.http.HttpServletResponse response)
Tries to assign further requests from a user to some other node, by setting a cookie. Result of the assignment attempt should be handled separately. For regular authentication through login pages, the redirect to the corresponding node is made by the page itself. No additional actions should be performed For passthrough (as injetbrains.buildServer.controllers.interceptors.AuthorizationInterceptorImpl
) the explicit redirect to the node must be made (seeProxyLoginSupport#sendRedirect
)- Parameters:
user
- userrequest
- requestresponse
- response- Returns:
- id of the node if assignment was made to some other node (as it require further processing),
null
if no node assignment was made - See Also:
WebLoginModelImpl.doLogin(boolean, HttpServletRequest, HttpServletResponse, Supplier)
,AuthorizationInterceptorImpl.preHandle(HttpServletRequest, HttpServletResponse, Object)
-
isEnabled
public static boolean isEnabled(@NotNull javax.servlet.http.HttpServletRequest request)
-
sendRedirect
public static void sendRedirect(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull String nodeId) throws IOException
Sends redirect to the same URL the initial request came from. AddsPARAM_REDIRECTED
to the query string to prevent infinite redirects- Parameters:
request
- initial requestresponse
- response- Throws:
IOException
- if something goes wrong
-
shouldRedirect
public static boolean shouldRedirect(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull String nodeId)
Checks whether redirect to the initial request's URL is required- See Also:
UsersLoadBalancer#sendRedirect(HttpServletRequest, HttpServletResponse)
,NODE_ID_PARAM
-
-