Skip to content

Commit

Permalink
https://github.com/ch4mpy/spring-addons/issues/174
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4mpy committed Jan 15, 2024
1 parent cf94263 commit 80acca7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ These starters are designed to push auto-configuration one step further. In most
I could forget to update README before releasing, so please refer to [maven central](https://repo1.maven.org/maven2/com/c4-soft/springaddons/spring-addons/) to pick latest available release
```xml
<properties>
<springaddons.version>7.3.1</springaddons.version>
<springaddons.version>7.3.2</springaddons.version>
</properties>
<dependencies>
Expand Down Expand Up @@ -518,6 +518,8 @@ I could forget to update README before releasing, so please refer to [maven cent
### 5.1. <a name="release-notes-7"/>`7.x` Branch
### `7.3.2` [gh-174](https://github.com/ch4mpy/spring-addons/issues/174) Fix a regression on request to exchange authorization-code for tokens in servlet applications
#### `7.3.1`
- [gh-173](https://github.com/ch4mpy/spring-addons/issues/173) prevent NPE. Thanks to [@yennor](https://github.com/yennor) for finding the bug and submitting a fix.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ public class SpringAddonsOidcClientProperties {
*/
private Optional<String> postLoginRedirectPath = Optional.empty();

/**
* Where to redirect the user after login failure
*/
private Optional<URI> loginErrorRedirectPath = Optional.empty();

/**
* HTTP status for redirections in OAuth2 login and logout. You might set this to something in 2xx range (like OK, ACCEPTED, NO_CONTENT, ...) for single
* page and mobile applications to handle this redirection as it wishes (change the user-agent, clear some headers, ...).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class SpringAddonsOauth2ServerAuthenticationFailureHandler implements Ser
private final SpringAddonsOauth2ServerRedirectStrategy redirectStrategy;

public SpringAddonsOauth2ServerAuthenticationFailureHandler(SpringAddonsOidcProperties addonsProperties) {
this.defaultRedirectUri = addonsProperties.getClient().getPostLoginRedirectUri().orElse(URI.create("/"));
this.defaultRedirectUri = addonsProperties.getClient().getLoginErrorRedirectPath().orElse(URI.create("/"));
this.redirectStrategy = new SpringAddonsOauth2ServerRedirectStrategy(addonsProperties.getClient().getOauth2Redirections().getPostAuthorizationCode());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,11 @@ public OAuth2AuthorizationRequest resolve(HttpServletRequest request, String cli
}

private OAuth2AuthorizationRequest toAbsolute(OAuth2AuthorizationRequest defaultAuthorizationRequest, HttpServletRequest request) {
final var requestUrl = request.getRequestURL();
if (defaultAuthorizationRequest == null || requestUrl == null) {
if (defaultAuthorizationRequest == null || clientUri == null) {
return defaultAuthorizationRequest;
}

final var original = URI.create(requestUrl.toString());
final var original = URI.create(defaultAuthorizationRequest.getRedirectUri());
final var redirectUri = UriComponentsBuilder
.fromUri(clientUri)
.path(original.getPath())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class SpringAddonsOauth2AuthenticationFailureHandler implements Authentic
private final SpringAddonsOauth2RedirectStrategy redirectStrategy;

public SpringAddonsOauth2AuthenticationFailureHandler(SpringAddonsOidcProperties addonsProperties) {
this.redirectUri = addonsProperties.getClient().getPostLoginRedirectUri().map(URI::toString).orElse("/");
this.redirectUri = addonsProperties.getClient().getLoginErrorRedirectPath().map(URI::toString).orElse("/");
this.redirectStrategy = new SpringAddonsOauth2RedirectStrategy(addonsProperties.getClient().getOauth2Redirections().getPostAuthorizationCode());
}

Expand Down

0 comments on commit 80acca7

Please sign in to comment.