-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59c4719
commit 80b92a8
Showing
89 changed files
with
2,169 additions
and
2,979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: maven | ||
name: build-back | ||
|
||
on: push | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: npm | ||
name: build-front | ||
|
||
on: push | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
backend/src/main/java/com/mercure/config/JwtAuthenticationEntryPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
106 changes: 41 additions & 65 deletions
106
backend/src/main/java/com/mercure/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,63 @@ | ||
package com.mercure.config; | ||
|
||
import com.mercure.service.CustomUserDetailsService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.authentication.AuthenticationManager; | ||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||
import org.springframework.security.config.Customizer; | ||
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.config.annotation.web.configurers.AbstractHttpConfigurer; | ||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
import org.springframework.security.web.csrf.CookieCsrfTokenRepository; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.CorsConfigurationSource; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Autowired | ||
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint; | ||
|
||
@Autowired | ||
private JwtWebConfig jwtWebConfig; | ||
|
||
@Autowired | ||
private CustomUserDetailsService customUserDetailsService; | ||
public class SecurityConfig { | ||
|
||
@Bean | ||
public PasswordEncoder passwordEncoder() { | ||
return new BCryptPasswordEncoder(); | ||
} | ||
|
||
@Bean | ||
@Override | ||
public AuthenticationManager authenticationManagerBean() throws Exception { | ||
return super.authenticationManagerBean(); | ||
} | ||
|
||
@Override | ||
protected void configure(AuthenticationManagerBuilder auth) throws Exception { | ||
auth.userDetailsService(customUserDetailsService).passwordEncoder(passwordEncoder()); | ||
} | ||
// @Bean | ||
// public CorsConfigurationSource corsConfigurationSource() { | ||
// CorsConfiguration configuration = new CorsConfiguration(); | ||
// configuration.setAllowedOrigins(List.of("http://localhost:3000")); | ||
// configuration.setAllowedMethods(Arrays.asList("GET", "POST", "OPTIONS")); | ||
// configuration.setAllowedMethods(List.of("*")); | ||
// configuration.setAllowedHeaders(List.of("*")); | ||
// configuration.setAllowCredentials(Boolean.TRUE); | ||
// UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
// source.registerCorsConfiguration("/**", configuration); | ||
// return source; | ||
// } | ||
|
||
@Bean | ||
public CorsConfigurationSource corsConfigurationSource() { | ||
CorsConfiguration configuration = new CorsConfiguration(); | ||
configuration.setAllowedOrigins(List.of("http://localhost:3000")); | ||
configuration.setAllowedMethods(Arrays.asList("GET", "POST")); | ||
configuration.setAllowedHeaders(List.of("*")); | ||
configuration.addAllowedOriginPattern("*"); | ||
configuration.setAllowCredentials(Boolean.TRUE); | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
source.registerCorsConfiguration("/**", configuration); | ||
return source; | ||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception { | ||
http | ||
.cors(Customizer.withDefaults()) | ||
.authorizeHttpRequests((auth) -> auth.anyRequest().permitAll()); | ||
return http.build(); | ||
} | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.cors().and() | ||
.csrf() | ||
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) | ||
.and() | ||
.authorizeRequests() | ||
.antMatchers("/api/auth").permitAll() | ||
.antMatchers("/api/user/register").permitAll() | ||
.antMatchers("/ws").permitAll() | ||
.antMatchers("/static/**").permitAll() | ||
.antMatchers("/images/**").permitAll() | ||
.antMatchers("/").permitAll() | ||
.anyRequest().authenticated() | ||
.and() | ||
.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint) | ||
.and() | ||
.sessionManagement() | ||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS); | ||
http.addFilterBefore(jwtWebConfig, UsernamePasswordAuthenticationFilter.class); | ||
} | ||
// protected void configure(HttpSecurity http) throws Exception { | ||
// http.cors().and() | ||
// .csrf() | ||
// .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()) | ||
// .and() | ||
// .authorizeRequests() | ||
// .antMatchers("/api/auth").permitAll() | ||
// .antMatchers("/api/user/register").permitAll() | ||
// .antMatchers("/ws").permitAll() | ||
// .antMatchers("/static/**").permitAll() | ||
// .antMatchers("/images/**").permitAll() | ||
// .antMatchers("/").permitAll() | ||
// .anyRequest().authenticated() | ||
// .and() | ||
// .exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint) | ||
// .and() | ||
// .sessionManagement() | ||
// .sessionCreationPolicy(SessionCreationPolicy.STATELESS); | ||
// http.addFilterBefore(jwtWebConfig, UsernamePasswordAuthenticationFilter.class); | ||
// } | ||
} |
Oops, something went wrong.