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:
arolfes 2023-11-14 22:16:09 +01:00
parent c59cdbca14
commit 71e5b4d566
8 changed files with 21 additions and 12 deletions

View File

@ -51,7 +51,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
@Override
@SuppressWarnings("removal")
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());
LOGGER.trace("Subject of caller: {}", subject);
if (subject != null) {
@ -129,7 +129,7 @@ public class CurrentUserContextImpl implements CurrentUserContext {
@SuppressWarnings("removal")
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());
LOGGER.trace("Subject of caller: {}", subject);
if (subject != null) {

View File

@ -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.configurers.AbstractHttpConfigurer;
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.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
@ -88,6 +89,7 @@ public class BootWebSecurityConfigurer {
} else {
addLoginPageConfiguration(http);
}
http.requestCache(RequestCacheConfigurer::disable);
return http.build();
}
@ -123,7 +125,12 @@ public class BootWebSecurityConfigurer {
authorizeHttpRequests -> authorizeHttpRequests.anyRequest().fullyAuthenticated())
.formLogin(
formLogin ->
formLogin.loginPage("/login").failureUrl("/login?error").defaultSuccessUrl("/"))
formLogin
.loginPage("/login")
.failureUrl("/login?error")
.defaultSuccessUrl("/index.html")
.permitAll()
)
.logout(
logout ->
logout
@ -131,7 +138,9 @@ public class BootWebSecurityConfigurer {
.clearAuthentication(true)
.logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
.logoutSuccessUrl("/login?logout")
.deleteCookies("JSESSIONID"));
.deleteCookies("JSESSIONID")
.permitAll()
);
}
protected JaasApiIntegrationFilter jaasApiIntegrationFilter() {

View File

@ -1,5 +1,5 @@
logging.level.pro.taskana=INFO
logging.level.org.springframework.security=INFO
logging.level.org.springframework=INFO
server.servlet.context-path=/taskana
taskana.routing.dmn.upload.path=/tmp/routing.dmn
######## Taskana DB #######

View File

@ -19,7 +19,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/"
"classpath:/static/", "classpath:/public/", "classpath:/templates/"
};
private final ObjectMapper objectMapper;

View File

@ -5,10 +5,10 @@ import org.springframework.web.bind.annotation.GetMapping;
/** The view controller. */
@Controller
public class ViewController {
public class TaskanaRedirectToIndexHtmlController {
@GetMapping(path = {"", "taskana/**"})
public String index() {
return "forward:/index.html";
return "redirect:/index.html";
}
}

View File

@ -56,7 +56,7 @@ public class ElytronToJaasFilter extends GenericFilterBean {
@SuppressWarnings("removal")
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());
if (logger.isDebugEnabled()) {
logger.debug("Current JAAS subject: " + subject);

View File

@ -68,7 +68,7 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
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()));
}

View File

@ -67,8 +67,8 @@ public class SpringSecurityToJaasFilter extends GenericFilterBean {
if (authentication.isEmpty() || !authentication.get().isAuthenticated()) {
return Optional.empty();
}
// TODO replace with Subject.current() when migrating to newer Version then 17
return Optional.of(Subject.getSubject(AccessController.getContext()));
// TODO replace with Subject.current() when migrating to newer Version than 17
return Optional.ofNullable(Subject.getSubject(AccessController.getContext()));
}
Optional<Authentication> getCurrentAuthentication() {