All checks were successful
CI - Build & Test (develop) / build-and-test (pull_request) Successful in 36s
121 lines
4.9 KiB
Java
Executable File
121 lines
4.9 KiB
Java
Executable File
//package io.gmss.fiscad.configuration;
|
|
//
|
|
//import com.backend.api.security.CustomUserDetailsService;
|
|
//import com.backend.api.security.JwtAuthenticationEntryPoint;
|
|
//import com.backend.api.security.JwtAuthenticationFilter;
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
|
//import org.springframework.context.annotation.Bean;
|
|
//import org.springframework.context.annotation.Configuration;
|
|
//import org.springframework.http.HttpMethod;
|
|
//import org.springframework.security.authentication.AuthenticationManager;
|
|
//import org.springframework.security.config.BeanIds;
|
|
//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
|
//import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
|
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
|
//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
//import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
|
//import org.springframework.security.config.http.SessionCreationPolicy;
|
|
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
//import org.springframework.security.crypto.password.PasswordEncoder;
|
|
//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
|
//
|
|
//@Configuration
|
|
//@EnableWebSecurity // active la sécurité web sur le projet
|
|
//@EnableGlobalMethodSecurity( // est utilisé pour définir la sécurité sur les méthodes
|
|
// securedEnabled = true, // est activé pour protéger un controlleur ou un service
|
|
// jsr250Enabled = true, // active le role qui doit être utilisé
|
|
// prePostEnabled = true // active le controle avant et après l'execution de la requête
|
|
//)
|
|
//public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|
//
|
|
// /**
|
|
// * Est utilisé pour authentifier un utlisateur ou pour définir un role
|
|
// */
|
|
// @Autowired
|
|
// CustomUserDetailsService customUserDetailsService;
|
|
//
|
|
// @Autowired
|
|
// private JwtAuthenticationEntryPoint unauthorizedHandler;
|
|
//
|
|
// @Bean
|
|
// public JwtAuthenticationFilter jwtAuthenticationFilter() {
|
|
// return new JwtAuthenticationFilter();
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
// private static final String[] AUTH_WHITELIST = {
|
|
//
|
|
// // -- swagger ui
|
|
// "/swagger-resources/**",
|
|
// "/swagger-ui.html",
|
|
// "/v3/api-docs",
|
|
// "/swagger-ui/**",
|
|
// "/webjars/**",
|
|
// "/api/**",
|
|
//// "/api/synonym/**",
|
|
// "/api/auth/**"
|
|
// };
|
|
// @Override
|
|
// public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
|
|
// authenticationManagerBuilder
|
|
// .userDetailsService(customUserDetailsService)
|
|
// .passwordEncoder(passwordEncoder());
|
|
// }
|
|
//
|
|
// @Bean(BeanIds.AUTHENTICATION_MANAGER)
|
|
// @Override
|
|
// public AuthenticationManager authenticationManagerBean() throws Exception {
|
|
// return super.authenticationManagerBean();
|
|
// }
|
|
//
|
|
// @Bean
|
|
// public PasswordEncoder passwordEncoder() {
|
|
// return new BCryptPasswordEncoder();
|
|
// }
|
|
//
|
|
// /**
|
|
// *
|
|
// * @param http
|
|
// * @throws Exception
|
|
// */
|
|
// @Override
|
|
// protected void configure(HttpSecurity http) throws Exception {
|
|
// http
|
|
// .cors()
|
|
// .and()
|
|
// .csrf()
|
|
// .disable()
|
|
// .exceptionHandling()
|
|
// .authenticationEntryPoint(unauthorizedHandler)
|
|
// .and()
|
|
// .sessionManagement()
|
|
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
// .and()
|
|
// .authorizeRequests()
|
|
// .antMatchers("/",
|
|
// "/favicon.ico",
|
|
// "/**/*.png",
|
|
// "/**/*.gif",
|
|
// "/**/*.svg",
|
|
// "/**/*.jpg",
|
|
// "/**/*.html",
|
|
// "/**/*.css",
|
|
// "/**/*.js")
|
|
// .permitAll()
|
|
// .antMatchers(AUTH_WHITELIST).permitAll()
|
|
// .antMatchers("/api/auth/**")
|
|
// .permitAll()
|
|
// .antMatchers("/api/user/checkUsernameAvailability", "/api/user/checkEmailAvailability")
|
|
// .permitAll()
|
|
// .antMatchers(HttpMethod.GET, "/api/polls/**", "/api/users/**")
|
|
// .permitAll()
|
|
// .anyRequest()
|
|
// .authenticated();
|
|
//
|
|
// // Add our custom JWT security filter
|
|
// http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
|
|
//
|
|
// }
|
|
//}
|