Ignore:
Timestamp:
04/19/23 21:19:08 (19 months ago)
Author:
Gjoko Kostadinov <gjoko.kostadinov@…>
Branches:
master
Children:
950fa0d
Parents:
9050790
Message:

Add admin functionality and business admin functionality.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/edu/gjoko/schedlr/config/AppSecurityConfig.java

    r9050790 r8bcd64c  
    22
    33import edu.gjoko.schedlr.services.PostgresUserDetailsService;
     4import lombok.AllArgsConstructor;
    45import org.springframework.context.annotation.Bean;
    56import org.springframework.context.annotation.Configuration;
     
    1112import org.springframework.security.config.core.GrantedAuthorityDefaults;
    1213import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
     14import org.springframework.security.web.access.AccessDeniedHandler;
     15import org.springframework.security.web.authentication.AuthenticationFailureHandler;
    1316import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
    1417import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
     
    1619@Configuration
    1720@EnableWebSecurity
     21@AllArgsConstructor
    1822public class AppSecurityConfig extends WebSecurityConfigurerAdapter {
    1923
     
    2428    private final AuthenticationSuccessHandler authenticationSuccessHandler;
    2529
    26     public AppSecurityConfig(PostgresUserDetailsService userDetailsService, BCryptPasswordEncoder passwordEncoder,
    27                              AuthenticationSuccessHandler authenticationSuccessHandler) {
    28         this.userDetailsService = userDetailsService;
    29         this.passwordEncoder = passwordEncoder;
    30         this.authenticationSuccessHandler = authenticationSuccessHandler;
    31     }
     30    private final AuthenticationFailureHandler authenticationFailureHandler;
    3231
    3332    @Bean
     
    4847                .authenticationEntryPoint(new AppAuthenticationEntryPoint())
    4948                .and()
    50                 .addFilterBefore(new AppFilter(), BasicAuthenticationFilter.class)
     49                .addFilterAfter(new AppFilter(userDetailsService), BasicAuthenticationFilter.class)
    5150                .formLogin()
    5251                .loginPage("/login")
    5352                .loginProcessingUrl("/login")
    5453                .successHandler(authenticationSuccessHandler)
     54                .failureHandler(authenticationFailureHandler)
    5555                .defaultSuccessUrl("/homepage")
    5656                .and()
Note: See TracChangeset for help on using the changeset viewer.