Skip to content

Commit f0ff897

Browse files
committed
AUT-2094 Send ui_locales and post_logout_redirect_uri as form parameters when using POST logout in govsso mode
1 parent 5fbcd81 commit f0ff897

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/main/java/ee/ria/govsso/client/controller/ClientController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class ClientController {
4646
private String applicationIntroLong;
4747
@Value("${example-client.messages.info-service}")
4848
private String applicationInfoService;
49+
@Value("${govsso.post-logout-redirect-uri}")
50+
private String postLogoutRedirectUri;
4951

5052
@GetMapping(value = LOGIN_VIEW_MAPPING, produces = MediaType.TEXT_HTML_VALUE)
5153
public ModelAndView clientLoginView(
@@ -83,6 +85,14 @@ public ModelAndView dashboard(@AuthenticationPrincipal OidcUser oidcUser, Exampl
8385
if (AccessTokenUtil.isJwtAccessToken(accessToken)) {
8486
model.addObject("access_token", accessToken);
8587
}
88+
String locale = LogoutUtil.getUiLocale(request);
89+
if (locale != null) {
90+
model.addObject("ui_locales", locale);
91+
}
92+
String postLogoutRedirectUri = LogoutUtil.postLogoutRedirectUri(request, this.postLogoutRedirectUri);
93+
if (postLogoutRedirectUri != null) {
94+
model.addObject("post_logout_redirect_uri", postLogoutRedirectUri);
95+
}
8696
}
8797

8898
log.info("Showing dashboard for subject='{}'", oidcUser.getSubject());

src/main/java/ee/ria/govsso/client/govsso/oauth2/GovssoClientInitiatedLogoutSuccessHandler.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ private String endpointUri(HttpServletRequest request, URI endSessionEndpoint, S
9494

9595
if (request.getMethod().equals(HttpMethod.GET.name())) {
9696
builder.queryParam("id_token_hint", idToken);
97-
}
98-
if (StringUtils.isNotEmpty(locale)) {
99-
builder.queryParam(UI_LOCALES_PARAMETER, locale);
100-
}
101-
if (postLogoutRedirectUri != null) {
102-
builder.queryParam("post_logout_redirect_uri", postLogoutRedirectUri);
97+
if (StringUtils.isNotEmpty(locale)) {
98+
builder.queryParam(UI_LOCALES_PARAMETER, locale);
99+
}
100+
if (postLogoutRedirectUri != null) {
101+
builder.queryParam("post_logout_redirect_uri", postLogoutRedirectUri);
102+
}
103103
}
104104

105105
return builder.encode(StandardCharsets.UTF_8)

src/main/resources/templates/dashboard.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@
2424
<li class="nav-item px-1 text-nowrap">
2525
<form method="post" th:action="@{/oauth/logout}" id="logoutFormPost">
2626
<input th:if="${authentication_provider == 'govsso'}"
27-
type="hidden" th:id="id_token_hint"
27+
type="hidden" id="id_token_hint"
2828
name="id_token_hint" th:value="${id_token}">
29+
<input th:if="${ui_locales}" type="hidden" id="ui_locales" name="ui_locales" th:value="${ui_locales}">
30+
<input th:if="${post_logout_redirect_uri}" type="hidden" id="post_logout_redirect_uri" name="post_logout_redirect_uri" th:value="${post_logout_redirect_uri}">
2931
<input class="btn btn-outline-secondary" name="logout_button" type="submit"
3032
th:value="${authentication_provider == 'govsso' ? 'Log out (POST)' : 'Log out'}"/>
3133
</form>

0 commit comments

Comments
 (0)