[java-idp-oidc] branch main updated: JOIDC-304 - Scope and iss parameters are not included in the form_post template

Codeberg noreply at shibboleth.net
Mon Nov 9 07:51:19 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-idp-oidc.

View the commit online:
https://codeberg.org/Shibboleth/java-idp-oidc/commit/52295c7f00613373a21e9de3df09ca6e691ebaae

The following commit(s) were added to refs/heads/main by this push:
     new 52295c7f JOIDC-304 - Scope and iss parameters are not included in the form_post template
52295c7f is described below

commit 52295c7f00613373a21e9de3df09ca6e691ebaae
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Mon Nov 9 09:50:12 2026 +0200

    JOIDC-304 - Scope and iss parameters are not included in the form_post template
    
    https://shibboleth.atlassian.net/browse/JOIDC-304
    
    Include the missing parameters into the template and cover in flow tests
---
 .../src/main/resources/templates/oidc-form-post.vm |  2 +
 .../oidc/op/profile/flow/AuthorizeFlowTest.java    | 90 ++++++++++++++++++++++
 2 files changed, 92 insertions(+)

diff --git a/idp-oidc-extension-impl/src/main/resources/templates/oidc-form-post.vm b/idp-oidc-extension-impl/src/main/resources/templates/oidc-form-post.vm
index a80873f4..63631d38 100644
--- a/idp-oidc-extension-impl/src/main/resources/templates/oidc-form-post.vm
+++ b/idp-oidc-extension-impl/src/main/resources/templates/oidc-form-post.vm
@@ -28,6 +28,8 @@
             #if($parameter_token_type)<input type="hidden" name="token_type" value="${parameter_token_type}" />#end
             #if($parameter_id_token)<input type="hidden" name="id_token" value="${parameter_id_token}" />#end
             #if($parameter_expires_in)<input type="hidden" name="expires_in" value="${parameter_expires_in}" />#end
+            #if($parameter_scope)<input type="hidden" name="scope" value="${parameter_scope}" />#end
+            #if($parameter_iss)<input type="hidden" name="iss" value="${parameter_iss}" />#end
             #if($parameter_error)<input type="hidden" name="error" value="${parameter_error}" />#end
             #if($parameter_error_description)<input type="hidden" name="error_description" value="${parameter_error_description}" />#end
             #if($parameter_error_uri)<input type="hidden" name="error_uri" value="${parameter_error_uri}" />#end
diff --git a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/AuthorizeFlowTest.java b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/AuthorizeFlowTest.java
index 0b0f6ac4..67a92511 100644
--- a/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/AuthorizeFlowTest.java
+++ b/idp-oidc-extension-impl/src/test/java/net/shibboleth/idp/plugin/oidc/op/profile/flow/AuthorizeFlowTest.java
@@ -32,6 +32,8 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.opensaml.storage.StorageService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -77,6 +79,7 @@ import net.shibboleth.idp.plugin.oidc.op.token.support.AccessTokenClaimsSet;
 import net.shibboleth.idp.plugin.oidc.op.token.support.AuthorizeCodeClaimsSet;
 import net.shibboleth.idp.session.SessionException;
 import net.shibboleth.oidc.profile.core.OidcError;
+import net.shibboleth.shared.codec.HTMLEncoder;
 import net.shibboleth.shared.collection.Pair;
 import net.shibboleth.shared.component.ComponentInitializationException;
 import net.shibboleth.shared.security.DataSealerException;
@@ -697,6 +700,47 @@ public class AuthorizeFlowTest extends AbstractOidcFlowTest {
         Assert.assertEquals(successResponse.getIssuer().getValue(), issuer);
     }
 
+    @Test
+    public void testWithAuthorizationCodeFlowIssInFormPostResponse() throws IOException, SessionException {
+        request.setMethod("GET");
+        final String state = idGenerator.generateIdentifier() + "<>&";
+        setRequestParameters(List.of(new Pair<>("client_id", "mockClientIdIssInResponse"),
+                new Pair<>("response_type", "code"),
+                new Pair<>("response_mode", "form_post"),
+                new Pair<>("scope", "openid profile"),
+                new Pair<>("state", state),
+                new Pair<>("redirect_uri", redirectUri)));
+        storeMetadata(storageService, clientIdIssInResponse, clientSecret, scope, redirectUri);
+
+        initializeThreadLocals();
+        
+        final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+        final AuthenticationResponse responseMessage = parseSuccessResponse(result, AuthenticationResponse.class);
+        final AuthenticationSuccessResponse successResponse = responseMessage.toSuccessResponse();
+        Assert.assertEquals(successResponse.getRedirectionURI().toString(), redirectUri);
+        Assert.assertNull(successResponse.getIDToken());
+        Assert.assertNull(successResponse.getAccessToken());
+        Assert.assertNotNull(successResponse.getAuthorizationCode());
+        Assert.assertNotNull(getSidFromAuthorizeCodeClaimsSet(successResponse));
+        Assert.assertNotNull(successResponse.getIssuer());
+        Assert.assertEquals(successResponse.getIssuer().getValue(), issuer);
+        final String responseForm = response.getContentAsString();
+        final Matcher issMatcher =
+                Pattern.compile("<input type=\"hidden\" name=\"iss\" value=\"([^\"]*)\"").matcher(responseForm);
+        if (issMatcher.find()) {
+            Assert.assertEquals(issMatcher.group(1), HTMLEncoder.encodeForHTMLAttribute(issuer));
+        } else {
+            Assert.fail("Could not find the iss from the response form");
+        }
+        final Matcher stateMatcher =
+                Pattern.compile("<input type=\"hidden\" name=\"state\" value=\"([^\"]*)\"").matcher(responseForm);
+        if (stateMatcher.find()) {
+            Assert.assertEquals(stateMatcher.group(1), HTMLEncoder.encodeForHTMLAttribute(state));
+        } else {
+            Assert.fail("Could not find the state from the response form");
+        }
+    }
+
     @Test
     public void testWithAuthorizationCodeFlowNoOpenidMetadataContainsResource() throws IOException, SessionException {
         request.setMethod("GET");
@@ -1541,6 +1585,52 @@ public class AuthorizeFlowTest extends AbstractOidcFlowTest {
         Assert.assertNull(claimsSet.getStringClaim("eduPersonScopedAffiliation"));
     }
 
+    @Test
+    public void testWithHybridIdTokenTokenFlowFormPostScopeFiltered() throws IOException, SessionException,
+        ParseException, DataSealerException {
+        request.setMethod("GET");
+        setRequestParameters(List.of(new Pair<>("client_id", "mockClientId"),
+                new Pair<>("response_type", "code id_token token"),
+                new Pair<>("scope", "openid profile to_be_filtered"),
+                new Pair<>("response_mode", "form_post"),
+                new Pair<>("redirect_uri", redirectUri),
+                new Pair<>("nonce", "idhas3h23hi13h1o2i32")));
+        storeMetadata(storageService, clientId, clientSecret, scope, redirectUri);
+
+        initializeThreadLocals();
+        
+        final FlowExecutionResult result = flowExecutor.launchExecution(FLOW_ID, null, externalContext);
+        final AuthenticationResponse responseMessage = parseSuccessResponse(result, AuthenticationResponse.class);
+        final AuthenticationSuccessResponse successResponse = responseMessage.toSuccessResponse();
+        Assert.assertEquals(successResponse.getRedirectionURI().toString(), redirectUri);
+        Assert.assertNotNull(successResponse.getIDToken());
+        Assert.assertNotNull(successResponse.getIDToken().getJWTClaimsSet().getClaim("c_hash"));
+        Assert.assertNotNull(successResponse.getIDToken().getJWTClaimsSet().getClaim("at_hash"));
+        Assert.assertNotNull(successResponse.getAccessToken());
+        Assert.assertNotNull(successResponse.getAuthorizationCode());
+        Assert.assertNull(successResponse.getIssuer());
+
+        final String sid1 = getSidFromOpaqueAccessTokenClaimsSet(successResponse);
+        final String sid2 = getSidFromAuthorizeCodeClaimsSet(successResponse);
+        Assert.assertEquals(sid1, sid2);
+
+        final AccessTokenClaimsSet token =
+                AccessTokenClaimsSet.parse(successResponse.getAccessToken().getValue(), getDataSealer());
+        Assert.assertEquals(token.getAudience(), Collections.singletonList(issuer));
+        final JWTClaimsSet claimsSet = token.getClaimsSet();
+        assert claimsSet != null;
+        Assert.assertNull(claimsSet.getStringClaim("eduPersonScopedAffiliation"));
+        Assert.assertEquals(successResponse.toParameters().get("scope").get(0), "openid profile");
+        final String responseForm = response.getContentAsString();
+        final Matcher matcher =
+                Pattern.compile("<input type=\"hidden\" name=\"scope\" value=\"([^\"]*)\"").matcher(responseForm);
+        if (matcher.find()) {
+            Assert.assertEquals(matcher.group(1), HTMLEncoder.encodeForHTMLAttribute("openid profile"));
+        } else {
+            Assert.fail("Could not find the scope from the response form");
+        }
+    }
+
     @Test
     public void testWithHybridIdTokenTokenFlowRequestObjectEnforcedNoRO() throws IOException, SessionException {
         request.setMethod("GET");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list