Skip to content

Add minor improvements#14164

Open
O-sura wants to merge 2 commits into
wso2:masterfrom
O-sura:master
Open

Add minor improvements#14164
O-sura wants to merge 2 commits into
wso2:masterfrom
O-sura:master

Conversation

@O-sura

@O-sura O-sura commented Apr 20, 2026

Copy link
Copy Markdown
Contributor
  • This PR adds some minor improvements to the validation logics

@coderabbitai

coderabbitai Bot commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Server-side validation for the request callback parameter was added to password-recovery and self-registration JSPs (both distributions). Callbacks are read raw, nulled when blank or equal (case-insensitively) to "null", or invalid per AuthenticationEndpointUtil.isValidMultiOptionURI(...). Hidden callback fields and link hrefs use the validated value and are HTML-encoded at render time.

Changes

Callback validation & rendering across authentication JSPs

Layer / File(s) Summary
Imports
all-in-one-apim/.../password-recovery.jsp, api-control-plane/.../password-recovery.jsp, all-in-one-apim/.../self-registration-username-request.jsp, api-control-plane/.../self-registration-username-request.jsp
Added/imported AuthenticationEndpointUtil, and in some files StringUtils, ApiException, and related imports to support validation.
Callback read & normalization
all-in-one-apim/.../self-registration-with-verification.jsp, api-control-plane/.../self-registration-with-verification.jsp, all-in-one-apim/.../self-registration-username-request.jsp, api-control-plane/.../self-registration-username-request.jsp, all-in-one-apim/.../password-recovery.jsp, api-control-plane/.../password-recovery.jsp
Read raw callback via request.getParameter("callback"); if blank or equalsIgnoreCase "null" set to null; otherwise obtain URL-encoded form (via IdentityManagementEndpointUtil.getURLEncodedCallback(...) where used) and validate with AuthenticationEndpointUtil.isValidMultiOptionURI(...); set to null on failure.
Flag / control flow
.../self-registration-username-request.jsp (both distributions)
isCallBackUrlEmpty now derived from StringUtils.isBlank(callback) so flow reflects validated/normalized value.
Rendering / output encoding
.../self-registration-with-verification.jsp, .../self-registration-username-request.jsp, .../password-recovery.jsp (both distributions)
Hidden <input name="callback"> and "go back" hrefs now use the validated callback; values are HTML-attribute-encoded at render time with Encode.forHtmlAttribute(callback). Hidden callback input is omitted when callback is null/blank.
Parameter copying / wiring
.../self-registration-username-request.jsp (both distributions)
When copying request parameters into hidden inputs, callback is excluded (alongside reCaptcha) so the raw parameter is not forwarded.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Add minor improvements' is vague and generic, using non-descriptive terminology that does not convey meaningful information about the specific changes to callback validation logic across multiple JSP files. Consider a more specific title such as 'Add server-side callback parameter validation across password recovery and registration endpoints' to clearly describe the main change.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description briefly mentions 'minor improvements to the validation logics' which is related to the changeset, though it lacks detail about the specific callback validation enhancements implemented across multiple JSP files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/password-recovery.jsp`:
- Around line 213-217: The callback value is not being normalized before
rendering the hidden field: ensure empty string and the literal "null" are
treated as null. In the JSP blocks that check callback (the if using
StringUtils.isBlank, StringUtils.equalsIgnoreCase(callback, "null"), and
AuthenticationEndpointUtil.isValidMultiOptionURI), change the logic to first
normalize callback by setting callback = null when StringUtils.isBlank(callback)
OR StringUtils.equalsIgnoreCase(callback, "null") OR
!AuthenticationEndpointUtil.isValidMultiOptionURI(callback); update both
occurrences (the current block around the first check and the similar block at
lines 219-223) so that only a non-blank, non-"null", valid multi-option URI
remains and the hidden field is not rendered with "" or "null".

In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp`:
- Around line 51-63: The code currently validates the callback into the local
variable callback (using AuthenticationEndpointUtil.isValidMultiOptionURI) but
later replays the original request parameter into the signup.do form, defeating
validation; update the form population logic so it does not write the raw
request parameter back — either omit replaying the "callback" parameter entirely
when generating hidden inputs (like reCaptcha is skipped) or always emit the
already-validated callback variable (and treat null/blank as absent). Locate the
form/output generation that iterates request parameters (the block that emits
inputs for signup.do) and change it to skip "callback" or substitute
request.getParameter("callback") with the validated callback variable and ensure
isCallBackUrlEmpty is respected. Ensure no other replay paths emit the
unvalidated callback.

In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`:
- Around line 196-201: Normalize the callback string by treating the literal
"null" (case-insensitive) as null first, then validate the raw callback value
with AuthenticationEndpointUtil.isValidMultiOptionURI(callback) before
URL-encoding; only call
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) after the raw
callback passes validation. In practice, update the block that currently uses
StringUtils.isBlank(callback), StringUtils.equalsIgnoreCase(callback, "null"),
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) and
AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback) so it first
sets callback = null when equalsIgnoreCase("null"), then calls
isValidMultiOptionURI(callback) on the raw value and only encodes with
getURLEncodedCallback(callback) if validation succeeds.

In
`@api-control-plane/modules/distribution/product/src/main/extensions/password-recovery.jsp`:
- Around line 213-217: The callback variable can be the empty string or the
literal "null" and still pass the subsequent null check, so before rendering the
hidden field ensure such values are normalized to null: update the code that
validates/uses callback (the callback variable, the block using StringUtils and
AuthenticationEndpointUtil.isValidMultiOptionURI) to first do if
(StringUtils.isBlank(callback) || StringUtils.equalsIgnoreCase(callback,
"null")) { callback = null; } and only then call
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) (or null-check
afterwards) so blank/"null" values are not preserved; apply the same
normalization wherever callback is later used (including the block around the
hidden field rendering).

In
`@api-control-plane/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp`:
- Around line 51-63: The sanitized callback handling is being bypassed because
the original request parameter "callback" is re-added later; fix by normalizing
blank or "null" values to null (as done in the existing validation using
callback and isCallBackUrlEmpty), then when rebuilding parameters for
replay/skipping the parameter-map loop and when rendering the hidden field for
"callback" ensure you only output the sanitized callback (the validated callback
variable) and skip any replay of request.getParameter("callback"); modify the
parameter replay loop (the code that iterates request.getParameterMap() and
re-emits fields) to exclude the "callback" key and ensure the hidden input for
signup.do uses the validated callback value and is omitted when callback ==
null.

In
`@api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`:
- Around line 196-201: Normalize and validate the raw callback value (not the
URL-encoded one) and treat the literal string "null" as blank: update the
condition around the callback handling to use a normalization like
StringUtils.trimToEmpty(callback) and check
StringUtils.isBlank(normalizedCallback) (or
StringUtils.equalsIgnoreCase(normalizedCallback, "null")) so the block runs only
for a meaningful value; then call
AuthenticationEndpointUtil.isValidMultiOptionURI(normalizedCallback) to validate
the raw callback and only after validation call
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) to produce
encodedCallback; adjust assignments so invalid or blank/"null" callbacks are set
to null consistently.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: afa66cb3-d16c-4af3-9a81-b5ffb1b11b56

📥 Commits

Reviewing files that changed from the base of the PR and between 86f5cae and d8f33a9.

📒 Files selected for processing (6)
  • all-in-one-apim/modules/distribution/product/src/main/extensions/password-recovery.jsp
  • all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp
  • all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/password-recovery.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp (1)

177-200: ⚠️ Potential issue | 🟡 Minor

Inconsistent handling between the two callback validation layers.

The callback is validated twice with different failure semantics: lines 178-185 forward to error.jsp when Utils.validateCallbackURL fails, whereas lines 196-200 silently nullify on isValidMultiOptionURI failure (falling back to the user portal URL at line 206). A callback that passes the first check but fails the second is therefore quietly rewritten rather than rejected. Consider either aligning both on the same outcome, or documenting why the second check is intentionally softer. Also, since the first block already guarantees callback is either blank or structurally valid, the "null" literal check is the primary new behavior added here.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`
around lines 177 - 200, The code inconsistently handles callback validation:
after Utils.validateCallbackURL(...) rejects the request by forwarding to
"error.jsp", the later
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) check silently nulls
the callback; change this to the same failure flow as the first check — when
callback is non-blank (and not the literal "null") but
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) returns false, set
request attributes (error=true and errorMsg using
IdentityManagementEndpointUtil.i18n(...) with an appropriate message) and
forward to "error.jsp" instead of nullifying callback so
Utils.validateCallbackURL and isValidMultiOptionURI have consistent semantics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In
`@api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`:
- Around line 177-200: The code inconsistently handles callback validation:
after Utils.validateCallbackURL(...) rejects the request by forwarding to
"error.jsp", the later
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) check silently nulls
the callback; change this to the same failure flow as the first check — when
callback is non-blank (and not the literal "null") but
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) returns false, set
request attributes (error=true and errorMsg using
IdentityManagementEndpointUtil.i18n(...) with an appropriate message) and
forward to "error.jsp" instead of nullifying callback so
Utils.validateCallbackURL and isValidMultiOptionURI have consistent semantics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 82b9f88f-d1ab-4e27-b318-a7cd116c47a6

📥 Commits

Reviewing files that changed from the base of the PR and between d8f33a9 and 0c97d72.

📒 Files selected for processing (3)
  • api-control-plane/modules/distribution/product/src/main/extensions/password-recovery.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp
🚧 Files skipped from review as they are similar to previous changes (1)
  • api-control-plane/modules/distribution/product/src/main/extensions/password-recovery.jsp

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp (1)

57-64: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep the sanitized callback authoritative in this form.

This all-in-one page still validates getURLEncodedCallback(callback) but submits the raw callback, and the hidden field is always emitted. So the value posted to signup.do is not the same value that was validated, and invalid/null callbacks are still replayed instead of being omitted like in the api-control-plane version.

Suggested fix
-    } else {
-        String encodedCallback = IdentityManagementEndpointUtil.getURLEncodedCallback(callback);
-        if (!AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback)) {
-            callback = null;
-        }
+    } else if (!AuthenticationEndpointUtil.isValidMultiOptionURI(callback)) {
+        callback = null;
     }
@@
-                        <input id="callback" name="callback" type="hidden"
-                               value="<%=Encode.forHtmlAttribute(callback)%>" class="form-control">
+                        <% if (StringUtils.isNotBlank(callback)) { %>
+                        <input id="callback" name="callback" type="hidden"
+                               value="<%=Encode.forHtmlAttribute(callback)%>" class="form-control">
+                        <% } %>
#!/bin/bash
# Compare the all-in-one and api-control-plane username-request pages.
rg -n -C3 'getURLEncodedCallback|isValidMultiOptionURI|id="callback"|name="callback"' \
  "all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp" \
  "api-control-plane/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp"

Also applies to: 195-197

🤖 Prompt for 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.

In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp`
around lines 57 - 64, The form is validating the URL-encoded value via
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) and
AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback) but still
emits and posts the original raw callback (hidden field id="callback"
name="callback"), causing invalid callbacks to be replayed to signup.do; change
the template so the sanitized/encoded callback is authoritative: compute
encodedCallback via getURLEncodedCallback(callback), only render the hidden
input when encodedCallback passes isValidMultiOptionURI(encodedCallback) and set
its value to encodedCallback (or set callback=null/omit input when invalid),
ensuring the value posted to signup.do matches what was validated.
all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp (1)

193-203: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate the raw callback in the all-in-one verification flow too.

This path still percent-encodes callback before calling isValidMultiOptionURI(), but later reuses the raw callback. The api-control-plane counterpart already validates the raw value, so this version can still approve a callback that was never checked in the same form it is propagated.

Suggested fix
-    } else {
-        String encodedCallback = IdentityManagementEndpointUtil.getURLEncodedCallback(callback);
-        if (!AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback)) {
-            callback = null;
-        }
+    } else if (!AuthenticationEndpointUtil.isValidMultiOptionURI(callback)) {
+        callback = null;
     }
#!/bin/bash
# Compare the all-in-one and api-control-plane self-registration-with-verification pages.
rg -n -C3 'getURLEncodedCallback|isValidMultiOptionURI|name="callback"' \
  "all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp" \
  "api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp"
🤖 Prompt for 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.

In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`
around lines 193 - 203, The code percent-encodes callback via
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) then validates
the encoded value with
AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback) but later
reuses the original raw callback, leaving an unvalidated raw value; change the
logic in the block that handles callback to first call
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) on the raw callback
and set callback = null if that fails, and only then produce/use an
encodedCallback (via getURLEncodedCallback) if needed; update references so that
AuthenticationEndpointUtil.isValidMultiOptionURI is invoked on the raw callback
variable and callback is nullified on failure to prevent propagating an
unchecked raw URL.
🤖 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
`@all-in-one-apim/modules/distribution/product/src/main/extensions/password-recovery.jsp`:
- Around line 212-219: The code validates the encoded callback (encodedCallback)
but later uses the original raw callback, allowing mismatches; change the flow
in the block that uses AuthenticationEndpointUtil.isValidMultiOptionURI and
IdentityManagementEndpointUtil.getURLEncodedCallback so you validate the raw
callback string first by calling
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) (or a raw-URI
validation helper) and only if that returns true produce and use
IdentityManagementEndpointUtil.getURLEncodedCallback(callback); ensure the
variable callback that is propagated is the validated/encoded value (or set to
null on failed validation) so validation and the propagated value match.

---

Duplicate comments:
In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp`:
- Around line 57-64: The form is validating the URL-encoded value via
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) and
AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback) but still
emits and posts the original raw callback (hidden field id="callback"
name="callback"), causing invalid callbacks to be replayed to signup.do; change
the template so the sanitized/encoded callback is authoritative: compute
encodedCallback via getURLEncodedCallback(callback), only render the hidden
input when encodedCallback passes isValidMultiOptionURI(encodedCallback) and set
its value to encodedCallback (or set callback=null/omit input when invalid),
ensuring the value posted to signup.do matches what was validated.

In
`@all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp`:
- Around line 193-203: The code percent-encodes callback via
IdentityManagementEndpointUtil.getURLEncodedCallback(callback) then validates
the encoded value with
AuthenticationEndpointUtil.isValidMultiOptionURI(encodedCallback) but later
reuses the original raw callback, leaving an unvalidated raw value; change the
logic in the block that handles callback to first call
AuthenticationEndpointUtil.isValidMultiOptionURI(callback) on the raw callback
and set callback = null if that fails, and only then produce/use an
encodedCallback (via getURLEncodedCallback) if needed; update references so that
AuthenticationEndpointUtil.isValidMultiOptionURI is invoked on the raw callback
variable and callback is nullified on failure to prevent propagating an
unchecked raw URL.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6861b730-445f-42e2-adc4-aff9d9d76e57

📥 Commits

Reviewing files that changed from the base of the PR and between 45a1878 and 48b52e9.

📒 Files selected for processing (6)
  • all-in-one-apim/modules/distribution/product/src/main/extensions/password-recovery.jsp
  • all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp
  • all-in-one-apim/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/password-recovery.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-username-request.jsp
  • api-control-plane/modules/distribution/product/src/main/extensions/self-registration-with-verification.jsp

@O-sura O-sura force-pushed the master branch 2 times, most recently from 6ade548 to 795c086 Compare May 6, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants