Skip to content
Closed
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 @@ -150,6 +150,9 @@ public static String buildAuthnRequestUrl(final String authnId, final SAMLProvid
if (spMetadata.getKeyPair() != null) {
privateKey = spMetadata.getKeyPair().getPrivate();
}
if (idpMetadata.getEntityId().startsWith("https://accounts.google.com/o/saml2?idpid=")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use URIBuilder instead, https://hc.apache.org/httpcomponents-core-5.1.x/5.1.1/httpcore5/apidocs/org/apache/hc/core5/net/URIBuilder.html
... or similar that helps generate the url based on a base URL and query params.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or search for ? in the idp entity url and based on that use correct concatenation strategy? (+ plus add unit tests)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searching for ? in the IdP url should be sufficient, since we only care about appending the SAML request query param to the URL.

#6457

redirectUrl = idpMetadata.getSsoUrl() + SAMLUtils.generateSAMLRequestSignature(SAMLUtils.encodeSAMLRequest(authnRequest), privateKey, signatureAlgorithm);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an else block here? Otherwise the redirectUrl will be overridden on the next line

redirectUrl = idpMetadata.getSsoUrl() + "?" + SAMLUtils.generateSAMLRequestSignature("SAMLRequest=" + SAMLUtils.encodeSAMLRequest(authnRequest), privateKey, signatureAlgorithm);
} catch (ConfigurationException | FactoryConfigurationError | MarshallingException | IOException | NoSuchAlgorithmException | InvalidKeyException | java.security.SignatureException e) {
s_logger.error("SAML AuthnRequest message building error: " + e.getMessage());
Expand Down