[JAVA-28947] Update Spring Activiti module to Spring Boot 3 (#16064)

This commit is contained in:
sam-gardner 2024-03-08 09:21:18 +00:00 committed by GitHub
parent f10bbc57fa
commit ddb9c4941b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 34 additions and 22 deletions

View File

@ -10,11 +10,19 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<artifactId>parent-boot-3</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
<relativePath>../parent-boot-3</relativePath>
</parent>
<repositories>
<repository>
<id>alfresco</id>
<name>alfresco</name>
<url>https://artifacts.alfresco.com/nexus/content/repositories/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.activiti</groupId>
@ -59,7 +67,7 @@
</build>
<properties>
<activiti.version>7.1.0.M6</activiti.version>
<activiti.version>8.0.0</activiti.version>
</properties>
</project>

View File

@ -3,11 +3,11 @@ package com.baeldung.activiti.security.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
@EnableWebMvc
public class MvcConfig extends WebMvcConfigurerAdapter {
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {

View File

@ -3,6 +3,7 @@ package com.baeldung.activiti.security.withspring;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
@ -14,28 +15,25 @@ public class SecurityConfig {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
http.antMatcher("/**")
.authorizeRequests()
.antMatchers("/protected-process*")
http.authorizeHttpRequests(auth -> auth
.requestMatchers("/protected-process*")
.authenticated()
.anyRequest()
.permitAll()
.and()
.formLogin()
.permitAll())
.formLogin(login -> login
.loginPage("/login")
.defaultSuccessUrl("/homepage")
.failureUrl("/login?error=true")
.and()
.csrf()
.disable()
.logout()
.logoutSuccessUrl("/login");
.permitAll())
.csrf(AbstractHttpConfigurer::disable)
.logout(logout -> logout.logoutSuccessUrl("/login"));
return http.build();
}
@Bean
public UserDetailsService userDetailsService() {
UserDetails user = User.withUsername("user")
User.UserBuilder users = User.withDefaultPasswordEncoder();
UserDetails user = users.username("user")
.password("{noop}pass")
.authorities("ROLE_ACTIVITI_USER")
.build();

View File

@ -0,0 +1,6 @@
<html>
<head></head>
<body>
<h1>Home page</h1>
</body>
</html>