first part #2434 fix configuration of example app
fix configuration of taskana-rest-spring-example-boot app to work properly after migration to Spring Boot 3.1
This commit is contained in:
parent
459c19dd51
commit
5ec0422acf
|
@ -51,7 +51,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
public List<String> getGroupIds() {
|
public List<String> getGroupIds() {
|
||||||
// TODO replace with Subject.current() when migrating to newer Version then 17
|
// TODO replace with Subject.current() when migrating to newer Version than 17
|
||||||
Subject subject = Subject.getSubject(AccessController.getContext());
|
Subject subject = Subject.getSubject(AccessController.getContext());
|
||||||
LOGGER.trace("Subject of caller: {}", subject);
|
LOGGER.trace("Subject of caller: {}", subject);
|
||||||
if (subject != null) {
|
if (subject != null) {
|
||||||
|
@ -129,7 +129,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
private String getUserIdFromJaasSubject() {
|
private String getUserIdFromJaasSubject() {
|
||||||
// TODO replace with Subject.current() when migrating to newer Version then 17
|
// TODO replace with Subject.current() when migrating to newer Version than 17
|
||||||
Subject subject = Subject.getSubject(AccessController.getContext());
|
Subject subject = Subject.getSubject(AccessController.getContext());
|
||||||
LOGGER.trace("Subject of caller: {}", subject);
|
LOGGER.trace("Subject of caller: {}", subject);
|
||||||
if (subject != null) {
|
if (subject != null) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.springframework.security.config.Customizer;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.RequestCacheConfigurer;
|
||||||
import org.springframework.security.config.ldap.LdapPasswordComparisonAuthenticationManagerFactory;
|
import org.springframework.security.config.ldap.LdapPasswordComparisonAuthenticationManagerFactory;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
@ -88,6 +89,7 @@ public class BootWebSecurityConfigurer {
|
||||||
} else {
|
} else {
|
||||||
addLoginPageConfiguration(http);
|
addLoginPageConfiguration(http);
|
||||||
}
|
}
|
||||||
|
http.requestCache(RequestCacheConfigurer::disable);
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +125,12 @@ public class BootWebSecurityConfigurer {
|
||||||
authorizeHttpRequests -> authorizeHttpRequests.anyRequest().fullyAuthenticated())
|
authorizeHttpRequests -> authorizeHttpRequests.anyRequest().fullyAuthenticated())
|
||||||
.formLogin(
|
.formLogin(
|
||||||
formLogin ->
|
formLogin ->
|
||||||
formLogin.loginPage("/login").failureUrl("/login?error").defaultSuccessUrl("/"))
|
formLogin
|
||||||
|
.loginPage("/login")
|
||||||
|
.failureUrl("/login?error")
|
||||||
|
.defaultSuccessUrl("/index.html")
|
||||||
|
.permitAll()
|
||||||
|
)
|
||||||
.logout(
|
.logout(
|
||||||
logout ->
|
logout ->
|
||||||
logout
|
logout
|
||||||
|
@ -131,7 +138,9 @@ public class BootWebSecurityConfigurer {
|
||||||
.clearAuthentication(true)
|
.clearAuthentication(true)
|
||||||
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
|
||||||
.logoutSuccessUrl("/login?logout")
|
.logoutSuccessUrl("/login?logout")
|
||||||
.deleteCookies("JSESSIONID"));
|
.deleteCookies("JSESSIONID")
|
||||||
|
.permitAll()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JaasApiIntegrationFilter jaasApiIntegrationFilter() {
|
protected JaasApiIntegrationFilter jaasApiIntegrationFilter() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
logging.level.pro.taskana=INFO
|
logging.level.pro.taskana=INFO
|
||||||
logging.level.org.springframework.security=INFO
|
logging.level.org.springframework=INFO
|
||||||
server.servlet.context-path=/taskana
|
server.servlet.context-path=/taskana
|
||||||
taskana.routing.dmn.upload.path=/tmp/routing.dmn
|
taskana.routing.dmn.upload.path=/tmp/routing.dmn
|
||||||
######## Taskana DB #######
|
######## Taskana DB #######
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
|
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
|
||||||
"classpath:/META-INF/resources/", "classpath:/resources/",
|
"classpath:/META-INF/resources/", "classpath:/resources/",
|
||||||
"classpath:/static/", "classpath:/public/"
|
"classpath:/static/", "classpath:/public/", "classpath:/templates/"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final ObjectMapper objectMapper;
|
private final ObjectMapper objectMapper;
|
||||||
|
|
|
@ -5,10 +5,10 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
/** The view controller. */
|
/** The view controller. */
|
||||||
@Controller
|
@Controller
|
||||||
public class ViewController {
|
public class TaskanaRedirectToIndexHtmlController {
|
||||||
|
|
||||||
@GetMapping(path = {"", "taskana/**"})
|
@GetMapping(path = {"", "taskana/**"})
|
||||||
public String index() {
|
public String index() {
|
||||||
return "forward:/index.html";
|
return "redirect:/index.html";
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -56,7 +56,7 @@ public class ElytronToJaasFilter extends GenericFilterBean {
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
@SuppressWarnings("removal")
|
||||||
private Subject obtainSubject() {
|
private Subject obtainSubject() {
|
||||||
// TODO replace with Subject.current() when migrating to newer Version then 17
|
// TODO replace with Subject.current() when migrating to newer Version than 17
|
||||||
Subject subject = Subject.getSubject(java.security.AccessController.getContext());
|
Subject subject = Subject.getSubject(java.security.AccessController.getContext());
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Current JAAS subject: " + subject);
|
logger.debug("Current JAAS subject: " + subject);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
|
||||||
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
|
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
// TODO replace with Subject.current() when migrating to newer Version then 17
|
// TODO replace with Subject.current() when migrating to newer Version than 17
|
||||||
return Optional.of(Subject.getSubject(AccessController.getContext()));
|
return Optional.of(Subject.getSubject(AccessController.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
|
||||||
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
|
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
// TODO replace with Subject.current() when migrating to newer Version then 17
|
// TODO replace with Subject.current() when migrating to newer Version than 17
|
||||||
return Optional.of(Subject.getSubject(AccessController.getContext()));
|
return Optional.ofNullable(Subject.getSubject(AccessController.getContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Authentication> getCurrentAuthentication() {
|
Optional<Authentication> getCurrentAuthentication() {
|
||||||
|
|
Loading…
Reference in New Issue