dagarcos пре 2 година
родитељ
комит
20e4e23658
2 измењених фајлова са 34 додато и 0 уклоњено
  1. 8 0
      pom.xml
  2. 26 0
      src/main/java/es/uv/garcosda/config/WebSecurityConfig.java

+ 8 - 0
pom.xml

@@ -42,6 +42,14 @@
 			<artifactId>spring-boot-starter-test</artifactId>
 			<scope>test</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-security</artifactId>
+		</dependency>
+		<dependency> 
+		    <groupId>org.springframework.boot</groupId> 
+		    <artifactId>spring-boot-starter-validation</artifactId> 
+		</dependency>
 	</dependencies>
 
 	<build>

+ 26 - 0
src/main/java/es/uv/garcosda/config/WebSecurityConfig.java

@@ -0,0 +1,26 @@
+package es.uv.garcosda.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.SecurityFilterChain;
+
+@Configuration
+@EnableWebSecurity
+public class WebSecurityConfig {
+	
+	@Bean
+	public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
+		
+		http.authorizeHttpRequests()
+			.requestMatchers("/login").permitAll()
+		    .anyRequest().authenticated()
+		    .and()
+		    .httpBasic();
+		
+		return http.build();
+	}
+	
+		
+}