Fix getting SUCCESS_COMPLETED as flowStatus for some error scenarios in App Native Authentication#3006
Open
VihangaMunasinghe wants to merge 3 commits intowso2-extensions:masterfrom
Open
Fix getting SUCCESS_COMPLETED as flowStatus for some error scenarios in App Native Authentication#3006VihangaMunasinghe wants to merge 3 commits intowso2-extensions:masterfrom
VihangaMunasinghe wants to merge 3 commits intowso2-extensions:masterfrom
Conversation
Comment on lines
+4837
to
+4838
| private static void handleApiBasedAuthError(String errorMsg) throws AuthServiceClientException { | ||
| if (StringUtils.isBlank(errorMsg)) { |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
Suggested change
| private static void handleApiBasedAuthError(String errorMsg) throws AuthServiceClientException { | |
| if (StringUtils.isBlank(errorMsg)) { | |
| private static void handleApiBasedAuthError(String errorMsg) throws AuthServiceClientException { | |
| log.error("API based authentication failed: {}", errorMsg); | |
| if (StringUtils.isBlank(errorMsg)) { |
Comment on lines
+4899
to
+4901
| String jsonPayload = new Gson().toJson(successCompleteAuthResponse); | ||
| oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true); | ||
| return Response.status(HttpServletResponse.SC_OK).entity(jsonPayload).build(); |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
Suggested change
| String jsonPayload = new Gson().toJson(successCompleteAuthResponse); | |
| oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true); | |
| return Response.status(HttpServletResponse.SC_OK).entity(jsonPayload).build(); | |
| String jsonPayload = new Gson().toJson(successCompleteAuthResponse); | |
| oAuthMessage.getRequest().setAttribute(IS_API_BASED_AUTH_HANDLED, true); | |
| log.info("API based authentication completed successfully"); | |
| return Response.status(HttpServletResponse.SC_OK).entity(jsonPayload).build(); |
Contributor
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
| Comment | Accepted (Y/N) | Reason |
|---|---|---|
| #### Log Improvement Suggestion No: 1 | ||
| #### Log Improvement Suggestion No: 2 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3006 +/- ##
============================================
+ Coverage 56.50% 56.53% +0.02%
+ Complexity 10413 10224 -189
============================================
Files 677 677
Lines 59374 59384 +10
Branches 14166 13921 -245
============================================
+ Hits 33552 33573 +21
+ Misses 21171 21160 -11
Partials 4651 4651
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In certain error scenarios during App Native Authentication, the system incorrectly returns
SUCCESS_COMPLETEDas theflowStatusinstead of a failure state.Examples of affected scenarios:
code_challengeorcode_challenge_methodis missing when PKCE is required.promptparameter in the request payload is invalid (e.g., usingnonewith other values or providing unsupported strings).Root Cause
The authentication framework handles error redirections through two primary paths:
redirect_urlwith error details appended as query parameters.The current logic for building App Native (API-based) responses only checks if the flow is redirected to the server error page. If the flow redirects back to the client side, the system ignores the error parameters attached to the URL and defaults to a
SUCCESS_COMPLETEDstatus, failing to communicate the failure to the API caller.Solution
The logic has been updated to inspect the redirection URL even when it points to the client side.
AuthServiceClientException.Testing
Before Merging
As the code changes the HTTP response for some App Native Requests, backward compatibility config should be included
Related Issue