Changeset 84d0fbb for trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java
- Timestamp:
- 12/19/21 19:39:00 (3 years ago)
- Branches:
- master
- Children:
- bdd6491
- Parents:
- 1ad8e64
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java
r1ad8e64 r84d0fbb 2 2 3 3 4 import finki.diplomska.tripplanner.service.impl.CustomUserDetailsServiceImpl; 4 5 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.context.annotation.Bean; 5 7 import org.springframework.context.annotation.Configuration; 8 import org.springframework.security.authentication.AuthenticationManager; 9 import org.springframework.security.config.BeanIds; 10 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 6 11 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 7 12 import org.springframework.security.config.annotation.web.builders.HttpSecurity; … … 9 14 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 15 import org.springframework.security.config.http.SessionCreationPolicy; 16 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 17 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; 18 19 import static finki.diplomska.tripplanner.security.SecurityConstants.MARIADB_URL; 20 import static finki.diplomska.tripplanner.security.SecurityConstants.SIGN_UP_URLS; 11 21 12 22 @Configuration … … 21 31 @Autowired 22 32 private JwtAuthenticationEntryPoint unauthorizedHandler; 33 34 @Autowired 35 private CustomUserDetailsServiceImpl customUserDetailsService; 36 37 @Bean 38 public JwtAuthenticationFilter jwtAuthenticationFilter() {return new JwtAuthenticationFilter();} 39 40 41 @Autowired 42 private BCryptPasswordEncoder bCryptPasswordEncoder; 43 44 @Override 45 protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { 46 authenticationManagerBuilder.userDetailsService(customUserDetailsService).passwordEncoder(bCryptPasswordEncoder); 47 } 48 49 @Override 50 @Bean(BeanIds.AUTHENTICATION_MANAGER) 51 protected AuthenticationManager authenticationManager() throws Exception { 52 return super.authenticationManager(); 53 } 23 54 24 55 @Override … … 43 74 "/**/*.js" 44 75 ).permitAll() 45 .antMatchers("/api/users/**").permitAll() 76 .antMatchers(SIGN_UP_URLS).permitAll() 77 .antMatchers(MARIADB_URL).permitAll() 46 78 .anyRequest().authenticated(); 79 http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class); 80 47 81 } 48 82 }
Note:
See TracChangeset
for help on using the changeset viewer.