Skip to content

Commit

Permalink
fix: exclude unsupported response types in exception (#2329)
Browse files Browse the repository at this point in the history
* fix: exclude unsupported response types in exception

- avoid logging or echoing unsantized input from the request
- this mirrors the change made to AuthorizationEndpoint in
spring-security-oauth2 2.5.2.RELEASE, see:
spring-attic/spring-security-oauth@2b58aaf

Change-Id: Id93034bc69355fcf988c56827fa65c70338694cf

* fix: allow bearer or Bearer for Authentication header

- apparently the whitespace is being trimmed off by spring in the xml
so the request matcher isn't doing a case insensitive comparison when
the header value is Bearer

Change-Id: I0f93cc2a0ebf364560687c4e57887a100753dd2d
  • Loading branch information
mikeroda committed May 22, 2023
1 parent 122579b commit 89523fb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public ModelAndView authorize(Map<String, Object> model,
String grantType = deriveGrantTypeFromResponseType(responseTypes);

if (!supported_response_types.containsAll(responseTypes)) {
throw new UnsupportedResponseTypeException("Unsupported response types: " + responseTypes);
throw new UnsupportedResponseTypeException("Unsupported response types");
}

if (authorizationRequest.getClientId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ else if (!matchesHeader(requestValue, expectedHeaderEntry.getValue())) {

private boolean matchesHeader(String requestValue, List<String> expectedValues) {
for (String headerValue : expectedValues) {
if ("bearer ".equalsIgnoreCase(headerValue)) {
if ("bearer".equalsIgnoreCase(headerValue.trim())) {
//case insensitive for Authorization: Bearer match
if (requestValue == null || !requestValue.toLowerCase().startsWith(headerValue)) {
return false;
Expand Down

0 comments on commit 89523fb

Please sign in to comment.