Skip to content

Commit

Permalink
cors y jwt
Browse files Browse the repository at this point in the history
  • Loading branch information
FMunoz99 committed Nov 24, 2024
1 parent fca9539 commit 2c8a303
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/example/proydbp/ProyDbpApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void addCorsMappings(CorsRegistry registry) {
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD","PATCH")
.maxAge(3600)
.allowedHeaders("*")
.allowCredentials(true);
.allowCredentials(false);
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,4 @@ public Page<ReviewMeseroResponseDto> getAllReviewMesero(@RequestParam int page,
public Page<ReviewDeliveryResponseDto> getAllReviewDelivery(@RequestParam int page, @RequestParam int size) {
return clientService.getAllReviewDelivery(page,size);
}





}
20 changes: 20 additions & 0 deletions src/main/java/com/example/proydbp/config/CorsConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.example.proydbp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig {

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
};
}
}
8 changes: 0 additions & 8 deletions src/main/java/com/example/proydbp/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@ public SecurityFilterChain securityFilterChain (HttpSecurity http) throws Except

.anyRequest().authenticated()
)
.exceptionHandling(exceptions ->
exceptions.authenticationEntryPoint(unauthorizedEntryPoint())
)
.build();
}

private AuthenticationEntryPoint unauthorizedEntryPoint() {
return (request, response, authException) -> {
response.sendError(HttpStatus.UNAUTHORIZED.value(), "Acceso no autorizado");
};
}

@Bean
public PasswordEncoder passwordEncoder() {
Expand Down
7 changes: 3 additions & 4 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
spring.application.name=ProyDBP



spring.datasource.url=jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
spring.datasource.username=${DB_USERNAME}
spring.datasource.password=${DB_PASSWORD}
Expand All @@ -17,10 +15,11 @@ spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.starttls.enable=true

server.port=8081
server.port=8080
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
logging.level.org.springframework.security.web=DEBUG
logging.level.org.springframework.web=DEBUG
logging.level.org.hibernate.SQL=DEBUG

spring.profiles.active=dev
spring.web.resources.static-locations=none

0 comments on commit 2c8a303

Please sign in to comment.