From bf327e53f10db833ec082d27429ecbdc5ee351d2 Mon Sep 17 00:00:00 2001 From: Rhys Nute <nuterd@cardiff.ac.uk> Date: Thu, 14 Dec 2023 06:32:23 +0000 Subject: [PATCH] added security --- .../security/SecurityConfiguration.java | 2 ++ .../Team5/SmartTowns/DataSourceConfig.java | 19 ------------------- 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 src/test/java/Team5/SmartTowns/DataSourceConfig.java diff --git a/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java b/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java index afce617e..ef2490fe 100644 --- a/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java +++ b/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java @@ -5,6 +5,7 @@ import org.springframework.context.annotation.Configuration; 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.configurers.AbstractHttpConfigurer; import org.springframework.security.crypto.password.NoOpPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.JdbcUserDetailsManager; @@ -23,6 +24,7 @@ public class SecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http + .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests((requests) -> requests .requestMatchers("/user/**", "/userProfile").authenticated() .anyRequest().permitAll() diff --git a/src/test/java/Team5/SmartTowns/DataSourceConfig.java b/src/test/java/Team5/SmartTowns/DataSourceConfig.java deleted file mode 100644 index 568065a2..00000000 --- a/src/test/java/Team5/SmartTowns/DataSourceConfig.java +++ /dev/null @@ -1,19 +0,0 @@ -package Team5.SmartTowns; - -import javax.sql.DataSource; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.DriverManagerDataSource; - -@Configuration -public class DataSourceConfig { - - @Bean - public DataSource dataSource(){ - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setUrl("jdbc:mariadb://localhost:3306/test_towns"); - dataSource.setUsername("root"); - dataSource.setPassword("comsc"); - return dataSource; - } -} \ No newline at end of file -- GitLab