Skip to content

[#1278] Preserve the goto destination during XUI logout - #1279

Open
vharseko wants to merge 3 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/1278-xui-logout-goto
Open

vharseko wants to merge 3 commits into
OpenIdentityPlatform:masterfrom
vharseko:fix/1278-xui-logout-goto

Conversation

@vharseko

@vharseko vharseko commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Fixes #1278

When a Web Policy Agent sends a user to /UI/Logout?goto=…, XUI can end the session and show Return to Login even though the agent supplied an allowed return URL.

The servlet filter now redirects to #logout/goto when the destination is in the query. XUI reads the destination from the original query and passes it to the existing validator before ending the session. The redirect carries one copy of the destination and keeps realm, locale, and other query parameters available during startup. This preserves escapes in the application's own URL and the requested language on the logged-out page.

Direct #logout/&goto=… links and destinations submitted in a logout form are also supported. The ordinary XUI logout menu ignores any return URL left in the address bar by an earlier login. An omitted or rejected destination follows the existing logout fallback.

All 6 XUIFilterTest tests and all 192 XUI tests passed. Tomcat 11.0.20 returned HTTP 302 with a 4,397-byte Location for a long destination. The XUI suite now asserts the rendered French heading in headless Chrome when validation rejects the destination with locale=fr, an English server default, and no language cookie. Temporarily removing the startup locale input makes that test fail with the English heading.

The reporter verified the direct XUI route on OpenAM 16.1.3 with Web Policy Agent 4.1.1. A live-agent round trip with this patch remains untested. Reporter’s confirmation

@vharseko vharseko added bug ui XUI / admin console / end-user UI labels Dec 4, 2026

@maximthomas maximthomas 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.

praise: The two new tests pin the encoded destination at the filter and validator boundaries, including an inner %2F, a literal plus sign, and an application fragment. Filter assertion · Validator assertion


issue (blocking): Duplicating a long goto in Location prevents the user from logging out.

Category bug, severity medium. XUIFilter.java L98–L104

The base sends the query once with #logout/. HEAD sends the same query and appends a second encoded goto inside the fragment. OpenAM's Docker distribution uses Tomcat 11 with the connector's default 8,192-byte response-header limit. If the two copies push Location over that limit, Tomcat sends HTTP 500 and the browser never reaches the XUI handler that ends the session. Base redirect · Docker image · Tomcat connector defaults

Temporary loopback check using the compiled filter from each pinned revision on Tomcat 11.0.20 with XUI enabled. Both runs used the same application search URL with an opaque state field and an explicit realm. A separate serializer check independently confirmed the response-header overflow.

request-header budget=8192 response-header budget=8192
base: encoded goto bytes=73   status=302 Location bytes=113
HEAD: encoded goto bytes=73   status=302 Location bytes=192
base: encoded goto bytes=4349 status=302 Location bytes=4389
HEAD: encoded goto bytes=4349 status=500 Location bytes=0
HEAD: org.apache.coyote.http11.HeadersTooLargeException

Keep a single copy of the destination in the redirect. The XUI handler could read the original query when the fragment supplies no goto, and preserve the direct fragment form. This blocker closes when an accepted long request produces a usable XUI redirect, preserves the realm and unrelated query parameters, and delivers the encoded destination once to the existing validator before logout.


issue (blocking): Adding goto to the fragment drops the requested locale on the logout fallback.

Category bug, severity medium. XUIFilter.java L98–L104

With locale=fr, a destination that the validator rejects, and an English server locale without a language cookie, the base redirect initializes XUI in French. HEAD appends &goto= in the fragment, and the Commons router then takes startup parameters exclusively from that fragment. The original query still contains locale=fr, but XUI initializes translations in English before logout and uses those translations on the logged-out view. Router parameter selection · XUI startup · Locale selection · Logged-out view

Independent component check with the Commons UI 3.2.2 router and locale manager. The check used the redirect forms from the two revisions and recorded the language passed to i18next.

Base: locale=fr, selected=fr
HEAD: locale=undefined, selected=en
HEAD after #loggedOut/: query locale visible again, initialized language=en

Preserve the query parameters used during XUI startup. This blocker closes when the rejected destination still leads to the French logged-out page and the accepted destination still reaches the validator with its URL escapes intact.

@vharseko

vharseko commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

@maximthomas, both findings are addressed in 61a9675.

  • Redirect size. The filter leaves the destination in the original query and emits #logout/goto. The XUI route passes the encoded destination once to the validator before logout. On Tomcat 11.0.20, the long-query check returned HTTP 302 with a 4,397-byte Location and preserved the full query. The explicit route also keeps the ordinary logout menu from picking up a stale login destination.
  • Fallback locale. The new fragment leaves the startup query visible to the Commons router. With locale=fr, an English server default, and a rejected destination, the logged-out view displayed “Vous êtes déconnecté.” in headless Chrome using a French test translation.

All 6 filter tests and all 192 XUI tests passed, including coverage for direct fragment links, form submissions, and URL escapes.

@vharseko
vharseko requested a review from maximthomas December 4, 2026 12:05

@maximthomas maximthomas 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.

praise: The long-destination test pins the entire Location, including realm, locale, and the application's escaped path and fragment. XUIFilterTest.java


suggestion (non-blocking): Assert the translated heading in the rejected-destination test.

Category test, severity low. validateLogoutGotoUrlTest.js

The test checks expect(locale).to.equal("fr") and the route sent to sendEvent. Those assertions would also pass if startup selected English after the router correctly parsed locale=fr. Exercise locale initialization and the logged-out view with a French translation fixture. The independent component check below verifies the current behavior.

Pin With an English server default, an empty language cookie, and a rejected destination, assert that the rendered <h1> equals the French fixture text.

@vharseko

vharseko commented Dec 4, 2026

Copy link
Copy Markdown
Member Author

@maximthomas, I extended the rejected-destination test to initialize XUI with an English server default and no language cookie, then assert that the rendered <h1> matches the French fixture for locale=fr. 9631ace57d

All 192 XUI tests pass. Temporarily removing the startup locale input makes only this test fail because the heading renders in English.

@vharseko
vharseko requested a review from maximthomas December 4, 2026 12:48

@maximthomas maximthomas 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.

praise: The rejected-destination test now renders the actual logout view and asserts the French <h1> with an English server default and no language-cookie override. Fixture and assertion

vharseko added a commit that referenced this pull request Dec 4, 2026
Starting with OpenAM 16.1.4, the default empty list of **Valid goto URL
Resources** allows relative URLs. An absolute URL qualifies without a
list entry only when it has a recognized OpenAM origin and its path is
within the OpenAM deployment context. If OpenAM runs at
`https://am.example.com/openam`, a user can sign in successfully and
still miss the redirect to `https://am.example.com/reports` unless the
authentication realm allows that destination.

The Configuration Reference and Administration Guide explain this rule,
including how the realm uses the service defaults. The Web Policy Agent
troubleshooting guide shows where to add destinations for co-hosted
applications and sibling subdomains, with examples for the application
root, a protected path, and a query string. This answers the [login
question in discussion
#1006](#1006 (reply in thread)).
The related logout change is tracked in [PR
#1279](#1279).

The Administration Guide also explains how the Validation Service
handles an omitted port. A literal `http` or `https` scheme uses port
`80` or `443`, respectively. The `http*` and `https*` scheme patterns
match any port when the port is omitted. The guide lists the supported
HTTP(S) scheme forms for absolute `goto` patterns and shows separate
HTTP and HTTPS patterns for deployments that allow only the standard
ports. Authorization Policies also shows how to use an explicit `:*`
with a `*://` scheme and a fixed host.

Antora rendered all four updated pages. I checked the cross-references
and verified that the wildcard examples rendered as literal code. A
focused check of the OpenAM 16.1.4 comparators confirmed that `http*`
and `https*` patterns without a port match HTTPS on `8443`. For the same
URL, a fixed-host `*://` pattern matched the nonrecursive policy
comparison with an explicit `:*`. The two literal-scheme patterns
restrict HTTP to `80` and HTTPS to `443`. All seven Antora page title
tests and all eight documentation checker tests passed, with no errors
in 145 How-To references across 56 pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug ui XUI / admin console / end-user UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XUI ignores the goto destination passed to /UI/Logout

2 participants