Skip to content

Commit 0e12799

Browse files
committed
work
1 parent 1d29412 commit 0e12799

File tree

2 files changed

+59
-33
lines changed

2 files changed

+59
-33
lines changed

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,9 @@
15301530

15311531
<profile>
15321532
<id>jar</id>
1533+
<activation>
1534+
<activeByDefault>false</activeByDefault>
1535+
</activation>
15331536
<properties>
15341537
<skip.unit.tests>true</skip.unit.tests>
15351538
<skip.integration.tests>true</skip.integration.tests>
@@ -1542,6 +1545,9 @@
15421545

15431546
<profile>
15441547
<id>docker</id>
1548+
<activation>
1549+
<activeByDefault>false</activeByDefault>
1550+
</activation>
15451551
<properties>
15461552
<skipTests>false</skipTests>
15471553
<skip.unit.tests>false</skip.unit.tests>
@@ -1561,6 +1567,9 @@
15611567

15621568
<profile>
15631569
<id>cloud</id>
1570+
<activation>
1571+
<activeByDefault>false</activeByDefault>
1572+
</activation>
15641573
<properties>
15651574
<skip.unit.tests>true</skip.unit.tests>
15661575
<skip.integration.tests>true</skip.integration.tests>
@@ -1573,6 +1582,9 @@
15731582

15741583
<profile>
15751584
<id>test</id>
1585+
<activation>
1586+
<activeByDefault>false</activeByDefault>
1587+
</activation>
15761588
<properties>
15771589
<skipTests>false</skipTests>
15781590
<skip.unit.tests>false</skip.unit.tests>
@@ -1587,6 +1599,9 @@
15871599

15881600
<profile>
15891601
<id>uml</id>
1602+
<activation>
1603+
<activeByDefault>false</activeByDefault>
1604+
</activation>
15901605
<properties>
15911606
<skip.unit.tests>true</skip.unit.tests>
15921607
<skip.integration.tests>true</skip.integration.tests>

src/main/java/org/woehlke/java/simpleworklist/config/WebSecurityConfig.java

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@
77
import org.springframework.context.annotation.Configuration;
88
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
99
import org.springframework.data.web.config.EnableSpringDataWebSupport;
10-
import org.springframework.http.HttpMethod;
1110
import org.springframework.scheduling.annotation.EnableAsync;
1211
import org.springframework.security.authentication.AuthenticationManager;
1312
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
1413
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
1514
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
1615
import org.springframework.security.config.annotation.web.builders.WebSecurity;
1716
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
18-
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
1917
import org.springframework.security.core.userdetails.UserDetailsService;
2018
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
2119
import org.springframework.security.crypto.password.PasswordEncoder;
20+
import org.springframework.security.web.SecurityFilterChain;
2221
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
2322
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
2423
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@@ -37,7 +36,7 @@
3736
@EnableConfigurationProperties({
3837
SimpleworklistProperties.class
3938
})
40-
public class WebSecurityConfig extends WebSecurityConfigurerAdapter implements WebSecurityConfigurer<WebSecurity> {
39+
public class WebSecurityConfig implements WebSecurityConfigurer<WebSecurity> {
4140

4241
private final AuthenticationManagerBuilder authenticationManagerBuilder;
4342
private final AuthenticationSuccessHandler authenticationSuccessHandler;
@@ -56,8 +55,48 @@ public WebSecurityConfig(
5655
this.simpleworklistProperties = simpleworklistProperties;
5756
}
5857

58+
@Bean
59+
public UserDetailsService userDetailsService(){
60+
return this.applicationUserDetailsService;
61+
}
62+
63+
/**
64+
* @see <a href="https://bcrypt-generator.com/">bcrypt-generator.com</a>
65+
* @return PasswordEncoder encoder
66+
*/
67+
@Bean
68+
public PasswordEncoder encoder(){
69+
int strength = simpleworklistProperties.getWebSecurity().getStrengthBCryptPasswordEncoder();
70+
return new BCryptPasswordEncoder(strength);
71+
}
72+
73+
@Bean
74+
public AuthenticationManager authenticationManager() throws Exception {
75+
return authenticationManagerBuilder
76+
.userDetailsService(userDetailsService())
77+
.passwordEncoder(encoder()).and().build();
78+
}
79+
80+
@Bean
81+
public UsernamePasswordAuthenticationFilter authenticationFilter() throws Exception {
82+
UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter();
83+
filter.setAuthenticationManager(authenticationManager());
84+
filter.setFilterProcessesUrl(simpleworklistProperties.getWebSecurity().getLoginProcessingUrl());
85+
return filter;
86+
}
87+
88+
@Override
89+
public void init(WebSecurity builder) throws Exception {
90+
91+
}
92+
5993
@Override
60-
protected void configure(HttpSecurity http) throws Exception {
94+
public void configure(WebSecurity builder) throws Exception {
95+
96+
}
97+
98+
@Bean
99+
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
61100
http
62101
.headers()
63102
.disable()
@@ -88,35 +127,7 @@ protected void configure(HttpSecurity http) throws Exception {
88127
.deleteCookies(simpleworklistProperties.getWebSecurity().getCookieNamesToClear())
89128
.invalidateHttpSession(simpleworklistProperties.getWebSecurity().getInvalidateHttpSession())
90129
.permitAll();
130+
return http.build();
91131
}
92132

93-
@Bean
94-
public UserDetailsService userDetailsService(){
95-
return this.applicationUserDetailsService;
96-
}
97-
98-
/**
99-
* @see <a href="https://bcrypt-generator.com/">bcrypt-generator.com</a>
100-
* @return PasswordEncoder encoder
101-
*/
102-
@Bean
103-
public PasswordEncoder encoder(){
104-
int strength = simpleworklistProperties.getWebSecurity().getStrengthBCryptPasswordEncoder();
105-
return new BCryptPasswordEncoder(strength);
106-
}
107-
108-
@Bean
109-
public AuthenticationManager authenticationManager() throws Exception {
110-
return authenticationManagerBuilder
111-
.userDetailsService(userDetailsService())
112-
.passwordEncoder(encoder()).and().build();
113-
}
114-
115-
@Bean
116-
public UsernamePasswordAuthenticationFilter authenticationFilter() throws Exception {
117-
UsernamePasswordAuthenticationFilter filter = new UsernamePasswordAuthenticationFilter();
118-
filter.setAuthenticationManager(authenticationManager());
119-
filter.setFilterProcessesUrl(simpleworklistProperties.getWebSecurity().getLoginProcessingUrl());
120-
return filter;
121-
}
122133
}

0 commit comments

Comments
 (0)