Streamline hawkBit logout behaviour (OIDC vs. Credentials) (#945)
* remove logout success handler bean in oidc configuration Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io> * changed logoutSuccessHandler for oidc configuration Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io> * set target url parameter to "/" instead of null Signed-off-by: Natalia Kislicyn <natalia.kislicyn@bosch.io>
This commit is contained in:
@@ -93,9 +93,7 @@ public class OidcUserManagementAutoConfiguration {
|
|||||||
*/
|
*/
|
||||||
@Bean
|
@Bean
|
||||||
public LogoutSuccessHandler oidcLogoutSuccessHandler() {
|
public LogoutSuccessHandler oidcLogoutSuccessHandler() {
|
||||||
SimpleUrlLogoutSuccessHandler logoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
|
return new OidcLogoutSuccessHandler();
|
||||||
logoutSuccessHandler.setDefaultTargetUrl("/");
|
|
||||||
return logoutSuccessHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,6 +224,24 @@ class OidcLogoutHandler extends SecurityContextLogoutHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LogoutSuccessHandler that decides where to redirect to after logout, depending on
|
||||||
|
* the previously used auth mechanism
|
||||||
|
*/
|
||||||
|
class OidcLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
|
||||||
|
throws IOException, ServletException {
|
||||||
|
if (authentication instanceof OAuth2AuthenticationToken) {
|
||||||
|
this.setTargetUrlParameter("/");
|
||||||
|
} else {
|
||||||
|
this.setTargetUrlParameter("login");
|
||||||
|
}
|
||||||
|
super.onLogoutSuccess(request, response, authentication);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to extract authorities out of the jwt. It interprets the user's
|
* Utility class to extract authorities out of the jwt. It interprets the user's
|
||||||
* role as their authorities.
|
* role as their authorities.
|
||||||
|
|||||||
Reference in New Issue
Block a user