|
@@ -2,6 +2,7 @@ package es.uv.garcosda.config;
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.security.config.annotation.method.configuration.EnableReactiveMethodSecurity;
|
|
|
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
|
|
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
|
@@ -9,6 +10,8 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.security.web.server.SecurityWebFilterChain;
|
|
|
|
|
|
+import reactor.core.publisher.Mono;
|
|
|
+
|
|
|
@EnableReactiveMethodSecurity
|
|
|
@EnableWebFluxSecurity
|
|
|
@Configuration
|
|
@@ -29,6 +32,14 @@ public class WebConfigSecurity {
|
|
|
)
|
|
|
.httpBasic()
|
|
|
.and()
|
|
|
+ .exceptionHandling()
|
|
|
+ .authenticationEntryPoint((swe, e) -> Mono.fromRunnable(() -> {
|
|
|
+ swe.getResponse().setStatusCode(HttpStatus.UNAUTHORIZED);
|
|
|
+ }))
|
|
|
+ .accessDeniedHandler((swe, e) -> Mono.fromRunnable(() -> {
|
|
|
+ swe.getResponse().setStatusCode(HttpStatus.FORBIDDEN);
|
|
|
+ }))
|
|
|
+ .and()
|
|
|
.build();
|
|
|
}
|
|
|
|