@Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http.headers().frameOptions().disable();
        http.csrf().disable();
        http.userDetailsService(userService);

        setLogin(http.formLogin());
        setLogout(http.logout());

        http.authorizeRequests()
                .antMatchers(securityProperties.getPermitUrl()).permitAll()
                .antMatchers(securityProperties.getGeneralUserUrl()).authenticated()
                .antMatchers("/api/v1/**").hasAuthority("admin")
                .anyRequest()
                .permitAll();
        http.exceptionHandling().defaultAuthenticationEntryPointFor((request, response, ex) ->
                        response.sendError(HttpServletResponse.SC_UNAUTHORIZED),
                request -> "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With")));
        return http.build();
    }
filterChain

@param http http
@return SecurityFilterChain
@throws Exception Exception
src/main/java/com/tuituidan/openhub/config/SecurityConfig.java