Skip to content
This repository has been archived by the owner on May 31, 2022. It is now read-only.

URISyntaxException on Invalid URLs when @EnableOAuth2Client is present #1140

Open
jcarvalho opened this issue Aug 18, 2017 · 1 comment
Open

Comments

@jcarvalho
Copy link

Description

When attempting to access a syntactically invalid URL (but allowed by the Browser), like /[], on a Spring application with the OAuth2 Client enabled (using @EnableOAuth2Client), an exception is thrown.

This seems to be caused by OAuth2ClientContextFilter use of ServletUriComponentsBuilder.fromRequest to compute the 'current URL', which is later used to implement AccessTokenRequest.getCurrentUri. As invalid URLs throw a URISyntaxException on fromRequest, an uncaught exception is raised, causing a 500 error.

Expected Behavior

The server returns a 4xx class error (like a 400 or a 404) or allows the filter chain to proceed.

Actual Behavior

The server returns a 500 error.

Steps to reproduce

  1. Create a new Spring Boot app with Web and Cloud OAuth2
  2. Add @EnableOAuth2Client to your app
  3. Navigate to http://localhost:8080/[]
@gwfong
Copy link

gwfong commented Jun 5, 2018

We are encountering this as well. In fact, the Spring error handling like @ControllerAdvice, etc, is not catching the error. The 500 and the stack trace for us is being sent to the client.

Any ideas on how to handle it?

Looks like this issue might be related to this: https://jira.spring.io/browse/SPR-16414

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants