8000 [OAuth] Prefer authorization error on redirect_uri by tdiesler · Pull Request #49237 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

[OAuth] Prefer authorization error on redirect_uri - #49237

Closed
tdiesler wants to merge 2 commits into
keycloak:mainfrom
tdiesler:ghi48542
Closed

tdiesler wants to merge 2 commits into
keycloak:mainfrom
tdiesler:ghi48542

Conversation

@tdiesler
@tdiesler tdiesler commented May 22, 2026 •
Copy link
Copy Markdown
Contributor

closes #48542

While processing an authorization request there are potential errors coming from

  1. checks in client policies
  2. various request parsers (e.g. url query, request object, request_uri)
  3. checks on request_uri, response_type, response_mode

most of these errors map to an unchecked ErrorPageException, which then displays an html error page.

When the request passes the above, errors tend to be reported back to the caller via redirect_uri already.

This PR proposes to first catch these ErrorPageExceptions and then (when configured to do so) make a "best effort" to use the redirect_uri path - otherwise, the error is returned to the caller as json object.

Without the authorization.preferErrorOnRedirect attribute on the client, this PR changes nothing. As a result, no test cases needed to be touched.

Automated conformance tests are headless - they prefer errors to be delivered on the redirect_uri when possible.

depends on

@tdiesler
tdiesler force-pushed the ghi48542 branch 3 times, most recently from e6f26ff to 9903564 Compare May 24, 2026 08:45
@tdiesler
tdiesler force-pushed the ghi48542 branch 5 times, most recently from da5f963 to 8615527 Compare June 2, 2026 06:25
@tdiesler
tdiesler marked this pull request as ready for review June 2, 2026 06:30
@tdiesler
tdiesler requested a review from a team as a code owner June 2, 2026 06:30
@mposolda mposolda self-assigned this Jun 5, 2026
@mposolda
mposolda commented Jun 5, 2026
Copy link
Copy Markdown
Contributor

@tdiesler Thanks for the PR.

I see the potential issues with the PR:

  • There is now more complex logic in AuthorizationEndpoint to detect whether to redirect or whether to show the error page. This introduces some additional fragility and complexity. We had often the security issues reported in the past with "open redirects" and "unsafe redirects". In general, with the recent security issues reported, the aim is to be more careful rather than introduce potentially unsafe/fragile logic...

  • There is new client attribute introduced (which is not even available in the admin console UI). And the only reason and use of this attribute is the conformance testsuite.

In general, this stuff (client attribute and complex logic) is done just because of the conformance testsuite. As in production, the client developers don't care much whether the error page is shown or whether there is redirect. If the client developer use incorrect parameter, he would be able to quickly figure it (regardless of whether there is error-page or redirect) and fix his client to use correct parameters (redirect_uri, response_type, response_mode or others).

TBH I would like to have more knowledge of what exactly is the problem, which we are trying to solve? AFAIK it is the fact that conformance testsuite is showing error page instead of redirect to client, which is harder to automate and test is not shown as "Green" in the results. Am I correct?

For the perspective of the certification conformance, the tests do not always need to be green. The state "review" is completely fine for the error tests to pass the certification. For example, Keycloak is certified FAPI provider. From this page with the certified providers [1] , you can click on the "View" link on the first item of Keycloak, which is this link [2]. It shows the successful certification results. As you can see, not all the tests were "Green", but there were some tests in "Review" . And having those tests in "Review" is completely fine for the certification. The test just needs to upload the image with the screenshot of the error page. Some example is this one [3] .

I am thinking if it is possible to automate the conformance testsuite with the tests in the "Review" state? Basically, the automated test can perform the screenshot, upload it, and continue to the next test. Would it be possible?

[1] https://openid.net/certification/certified-fapi1-adv-openid-providers-profiles/
[2] https://www.certification.openid.net/plan-detail.html?public=true&plan=iuw4ZWVuzPwkH&_gl=1*iqulcm*_ga*MTIzMTAwODE1My4xNzQ1Mzk3MzY3*_ga_NF8HNLNJJE*czE3ODA2NzIzMTYkbzE2JGcxJHQxNzgwNjc0MDE3JGo5JGwwJGgw&_ga=2.186734184.1151493263.1780672317-1231008153.1745397367
[3] https://www.certification.openid.net/log-detail.html?log=NienrLprjipAAI1&public=true

CyanoFresh and others added 2 commits June 8, 2026 16:30
…request-object-not-used

closes keycloak#48047

Signed-off-by: Thomas Diesler <tdiesler@proton.me>
closes keycloak#48542

Signed-off-by: Thomas Diesler <tdiesler@proton.me>
@tdiesler
tdiesler marked this pull request as draft June 8, 2026 17:40
@tdiesler
tdiesler commented Jun 9, 2026 •
Copy link
Copy Markdown
Contributor Author

Ok, lets try a different approach.

I propose to leave the authorization handling unchanged and first collect all conditions were it would not work in headless environments, one of which being the automated conformance tests.

The first such error condition is described here.

PR #49788 now contains the changes from this PR to make fapi2-security-profile-final-state-only-outside-request-object-not-used pass with "review required" (i.e. needs a screen shoot upload)

When all error conditions are collected in that way, we likely have a better view of what is actually needed to improve headless authorization. Let's skip these changes for now and perhaps revisit later 8000 .

@tdiesler tdiesler closed this Jun 9, 2026
@tdiesler
tdiesler deleted the ghi48542 branch June 9, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[OAuth] Prefer authorization error on redirect_uri

4 participants

0