...
| Bloque de código |
|---|
########## RUTA BASE REST ########## server.servlet.context-path=/api ########## BASE DE DATOS ########## # Dialecto de hibernate para conectarse a base de datos spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect # Validar la conexión de base de datos al iniciar la aplicación spring.jpa.hibernate.ddl-auto = validate # Permitir obtener propiedades lazy sin necesidad de mantener la sesión spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true # Driver del datasource spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver # Url JDBC del datasource spring.datasource.url=jdbc:oracle:thin:@hydra-prescan.atica.um.es:1526/ZEUSDESA # Usuario de base de datos spring.datasource.username=USER # Contraseña spring.datasource.password=PASSWORD |
...
| Bloque de código | ||
|---|---|---|
| ||
package es.um.atica.helloworld.config;
import java.util.Arrays;
import org.springframework.context.annotation.Bean;
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.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
// CORS y HTTPS obligatorio:
http.cors().and().requiresChannel().anyRequest().requiresSecure();
// SóloSolo CORS:
// http.cors();
}
// Filtro CORS
@Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOriginPatterns(Arrays.asList("*"));
configuration.setAllowedMethods(Arrays.asList("*"));
configuration.setAllowedHeaders(Arrays.asList("*"));
configuration.setAllowCredentials(true);
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
} |
...