[ES 2924] Prompt Validation before id token hint to propogate right error code#1904
[ES 2924] Prompt Validation before id token hint to propogate right error code#1904KashiwalHarsh wants to merge 3 commits into
Conversation
Signed-off-by: Harsh Kashiwal <harsh.kashiwal@infosys.com>
Signed-off-by: Harsh Kashiwal <harsh.kashiwal@infosys.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAll OAuth detail endpoints (V2, V3, PAR) now route through buildTransactionAndOAuthDetailResponse which conditionally processes id_token_hint; id_token_hint validation failures now throw LOGIN_REQUIRED. Tests updated to reflect the new error semantics and required mocks. ChangesCentralize id_token_hint processing with error code alignment
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.java`:
- Around line 518-520: The cast to OAuthDetailRequestV3 in
AuthorizationServiceImpl when idTokenHint != null is unsafe; before casting
oauthDetailReqDto, verify its type (e.g., oauthDetailReqDto instanceof
OAuthDetailRequestV3) and handle the mismatch by either throwing a clear
IllegalArgumentException/BadRequest or falling back to a safe path, then call
handleIdTokenHint((OAuthDetailRequestV3) oauthDetailReqDto, httpServletRequest)
only after the check; reference oauthDetailReqDto, OAuthDetailRequestV3,
handleIdTokenHint and the surrounding conditional to locate where to add the
defensive check and error handling.
In
`@oidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java`:
- Around line 1166-1171: The test is ambiguous because it both asserts a
non-null OAuthDetailResponseV2 and catches EsignetException expecting
ErrorConstants.LOGIN_REQUIRED; since the JWT audience
("mosip-signup-oauth-client") does not match oauthDetailRequest.clientId
("34567") the test should explicitly expect failure: replace the try/catch block
around AuthorizationServiceTest.getOauthDetailsV3(oauthDetailRequest, request)
with an assertion that the call throws EsignetException (e.g., assertThrows) and
then assert the thrown exception's errorCode equals
ErrorConstants.LOGIN_REQUIRED; alternatively, if you intend success, change the
test fixture so oauthDetailRequest.clientId matches the JWT audience before
calling getOauthDetailsV3.
- Around line 728-755: The test currently fails to reach the cookie-null branch
in AuthorizationServiceImpl#handleIdTokenHint because
authorizationHelperService.validateAndGetSubjectAndNonce(...) is causing an
earlier failure; update the test to mock
authorizationHelperService.validateAndGetSubjectAndNonce(...) to return a valid
subject/nonce (or otherwise not throw) so getOauthDetailsV3(...) proceeds to the
cookie check, then change the asserted error to
ErrorConstants.INVALID_ID_TOKEN_HINT (or if you meant to test the earlier
validation, instead keep the existing mocks and assert
ErrorConstants.LOGIN_REQUIRED). Ensure you reference
authorizationHelperService.validateAndGetSubjectAndNonce,
AuthorizationServiceImpl.handleIdTokenHint, getOauthDetailsV3, and
ErrorConstants.INVALID_ID_TOKEN_HINT when making the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: e128ac83-a8f8-4a33-9216-4daf10de0282
📒 Files selected for processing (3)
oidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationHelperService.javaoidc-service-impl/src/main/java/io/mosip/esignet/services/AuthorizationServiceImpl.javaoidc-service-impl/src/test/java/io/mosip/esignet/services/AuthorizationServiceTest.java
Signed-off-by: Harsh Kashiwal <harsh.kashiwal@infosys.com>
|
Actionable comments posted: 0 |
Summary by CodeRabbit
Bug Fixes
Refactor
Tests