Repository navigation
Make the hybrid branch in GrantTypeCondition reachable - #52474
HuzaifaChaudary wants to merge 1 commit into
Conversation
| @@ -100,15 +100,16 @@ private boolean isGrantMatching(AuthorizationRequestContext request) { | |||
| if (request == null) return false; | |||
| try { | |||
| OIDCResponseType parsedResponseType = OIDCResponseType.parse(request.getAuthorizationEndpointRequest().getResponseType()); | |||
There was a problem hiding this comment.
Could this use request.getParsedResponseType() instead of re-parsing the raw string?
AuthorizationEndpoint parses it once in checkResponseType() and passes the result into the context (L172, L211), and the AUTHORIZATION_REQUEST event only fires once that check has passed, so the field is non-null and equal to what this line recomputes. It would also make the IllegalArgumentException catch below unnecessary.
There was a problem hiding this comment.
yes , you are right . line 211 is the only place that builds this context and it comes after checkResponseType , which either sets the field or returns the error redirect . so the parse here could never fail and the catch was dead . the re parse was there before this change , i kept it without looking at where the context comes from .
done in 1594fd5 . the tests already passed a parsed type into the context so they did not need to change . mvn -pl services test is still 684 passing , and putting the old branch order back still gives [NO, NO, NO] on the hybrid test .
1594fd5 to
21ebd38
Compare
|
rebased on main to clear the conflict . main added the added |
|
@mposolda could you take a look when you have time ? the grant type condition never matched |
graziang
left a comment
There was a problem hiding this comment.
@HuzaifaChaudary thanks! @jimmychakkalakal do you want to take another look?
jimmychakkalakal
left a comment
There was a problem hiding this comment.
Thanks @HuzaifaChaudary LGTM, I approve the PR from my end
the third branch could never run. to get to it you need no code in the response type, and with no code isImplicitFlow and isImplicitOrHybridFlow are the same test, so if the second branch is false the third one is false too. that means response_type=code token went to the first branch and only ever checked authorization_code. a policy set up with grant_types=[implicit] voted no on it, so an executor meant to cover the front channel token never ran, even though the redirect carries one. putting implicit first, then hybrid, then code makes the branch the original author already wrote reachable. nothing inside the branches changed. plain code and plain implicit still land where they did before. Signed-off-by: Huzaifa Iftikhar <chhuzaifaiftikhar@gmail.com>
21ebd38 to
4dbcc34
Compare
|
@HuzaifaChaudary Thanks! Could you please fix the compilation error? Hopefully the PR is close to merge. |
Closes #51159
the third branch in
GrantTypeCondition.isGrantTypeMatchingcan never run :to reach 3 you need no
codein the response type . but with nocode,isImplicitFlow()is(token || id_token) && !codeandisImplicitOrHybridFlow()is(token || id_token), which are the same test . so if 2 is false , 3 is false too .what that costs :
response_type=code tokengoes to branch 1 and only ever checksauthorization_code. a policy set up withgrant_types=[implicit]votes no on it , so anexecutor meant to cover the front channel token never runs , even though the redirect carries
one . same for
code id_tokenandcode id_token token.putting implicit first , then hybrid , then code makes the branch reachable . nothing inside
the branches changed , it is a reorder plus a comment . plain
codestill matchesauthorization_code, plain implicit still matchesimplicit,nonestill returns false ,and hybrid with
grant_types=[authorization_code]still votes yes .five tests added . one fails without the change , all three hybrid types come back
[NO, NO, NO]where they should be[YES, YES, YES]. the other four pin the cases that mustnot move and pass either way .
mvn -pl services testis 684 passing , 0 failures . the tree without this runs 679 , so theonly difference is the five new ones .
spotless:checkis clean .i could not run the integration suites , docker is not available on this machine . i checked
by hand that no integration test asserts the old behaviour :
ClientPoliciesTesttestClientGrantTypeConditiononly sendsresponse_type=codeagainstgrant_types=[authorization_code], which is unchanged here , andtestProhibitedImplicitOrHybridFlowusesAnyClientConditionwithRejectImplicitGrantExecutor, not this class .ai usage , per the generative ai section of CONTRIBUTING . i used claude code ( claude opus 5 )
as an agent to help find the dead branch , write the patch and the tests , and draft this
description . i went through the reasoning myself , confirmed the branch is unreachable from
the two predicate definitions , and ran everything quoted above locally .