coheigea commented on code in PR #3281:
URL: https://github.com/apache/cxf/pull/3281#discussion_r3637208780


##########
rt/rs/security/sso/saml/src/main/java/org/apache/cxf/rs/security/saml/sso/SAMLSSOResponseValidator.java:
##########
@@ -169,8 +169,8 @@ private void 
validateIssuer(org.opensaml.saml.saml2.core.Issuer issuer) throws W
             return;
         }
 
-        // Issuer value must match (be contained in) Issuer IDP
-        if (enforceKnownIssuer && (issuer.getValue() == null || 
!issuerIDP.startsWith(issuer.getValue()))) {
+        // Issuer value must match the configured Issuer IDP
+        if (enforceKnownIssuer && !issuerIDP.equals(issuer.getValue())) {

Review Comment:
   How about something like this as a middle ground? We could make it 
configurable as well to accept strict matching only.
   ```
   private boolean matchesKnownIssuer(String issuerValue) {
           if (issuerValue == null || issuerIDP == null || 
!issuerIDP.startsWith(issuerValue)) {
               return false;
           }
   
           if (issuerIDP.equals(issuerValue)) {
               return true;
           }
   
           // Keep prefix compatibility, but for URL-based IdP values require a 
URL-based issuer
           // on the same scheme/host/port to avoid accepting arbitrary short 
prefixes.
           URI issuerIdpUri = toUri(issuerIDP);
           if (isHierarchicalAbsoluteUri(issuerIdpUri)) {
               URI issuerUri = toUri(issuerValue);
               return isHierarchicalAbsoluteUri(issuerUri)
                   && 
issuerIdpUri.getScheme().equalsIgnoreCase(issuerUri.getScheme())
                   && 
issuerIdpUri.getHost().equalsIgnoreCase(issuerUri.getHost())
                   && getEffectivePort(issuerIdpUri) == 
getEffectivePort(issuerUri);
           }
   
           return true;
       }
   
       private URI toUri(String value) {
           try {
               return URI.create(value);
           } catch (IllegalArgumentException ex) {
               return null;
           }
       }
   
       private boolean isHierarchicalAbsoluteUri(URI uri) {
           return uri != null && uri.isAbsolute() && uri.getHost() != null;
       }
   
       private int getEffectivePort(URI uri) {
           if (uri.getPort() != -1) {
               return uri.getPort();
           }
           if ("http".equalsIgnoreCase(uri.getScheme())) {
               return 80;
           }
           if ("https".equalsIgnoreCase(uri.getScheme())) {
               return 443;
           }
           return -1;
       }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to