-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AUT-2042 Change Spring default logout behaviour to ensure http method…
… is not changed during redirect and send request content with form parameters when POST log out is used
- Loading branch information
Showing
8 changed files
with
132 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package ee.ria.govsso.client.util; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpSession; | ||
import lombok.experimental.UtilityClass; | ||
import org.springframework.security.web.util.UrlUtils; | ||
import org.springframework.web.util.UriComponents; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
import java.util.Collections; | ||
import java.util.Locale; | ||
|
||
import static org.springframework.web.servlet.i18n.SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME; | ||
|
||
@UtilityClass | ||
public class LogoutUtil { | ||
|
||
public String postLogoutRedirectUri(HttpServletRequest request, String postLogoutRedirectUri) { | ||
if (postLogoutRedirectUri == null) { | ||
return null; | ||
} | ||
UriComponents uriComponents = UriComponentsBuilder | ||
.fromHttpUrl(UrlUtils.buildFullRequestUrl(request)) | ||
.replacePath(request.getContextPath()) | ||
.replaceQuery(null) | ||
.fragment(null) | ||
.build(); | ||
return UriComponentsBuilder.fromUriString(postLogoutRedirectUri) | ||
.buildAndExpand(Collections.singletonMap("baseUrl", uriComponents.toUriString())) | ||
.toUriString(); | ||
} | ||
|
||
public String getUiLocale(HttpServletRequest request) { | ||
HttpSession session = request.getSession(false); | ||
if (session == null) { | ||
return null; | ||
} else if (session.getAttribute(LOCALE_SESSION_ATTRIBUTE_NAME) instanceof Locale locale) { | ||
return locale.getLanguage(); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters