Skip to content

Commit 1b58362

Browse files
committed
fixes #75: handle the idp url already having a query parameter
1 parent 7b9816b commit 1b58362

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

core/src/main/java/com/onelogin/saml2/util/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public static void sendRedirect(HttpServletResponse response, String location, M
570570
String target = location;
571571

572572
if (!parameters.isEmpty()) {
573-
Boolean first = true;
573+
boolean first = !location.contains("?");
574574
for (Map.Entry<String, String> parameter : parameters.entrySet())
575575
{
576576
if (first) {

core/src/test/java/com/onelogin/saml2/test/util/UtilsTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2107,4 +2107,16 @@ public void testQuery() throws XPathExpressionException, URISyntaxException, IOE
21072107
Node assertion_2 = assertionNodes_2.item(0);
21082108
assertEquals("saml2:Assertion", assertion_2.getNodeName());
21092109
}
2110+
2111+
@Test
2112+
public void sendRedirectToShouldHandleUrlsWithQueryParams() throws Exception {
2113+
// having
2114+
final HttpServletResponse response = mock(HttpServletResponse.class);
2115+
2116+
// when
2117+
Util.sendRedirect(response, "https://sso.connect.pingidentity.com/sso/idp/SSO.saml2?idpid=ffee-aabbb", Collections.singletonMap("SAMLRequest", "data"));
2118+
2119+
// then
2120+
verify(response).sendRedirect("https://sso.connect.pingidentity.com/sso/idp/SSO.saml2?idpid=ffee-aabbb&SAMLRequest=data");
2121+
}
21102122
}

0 commit comments

Comments
 (0)