Commit 27a12d01 authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade soporte para CORS

parent 43b8c4c7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
	<groupId>es.redmic.time-series</groupId>
	<artifactId>time-series</artifactId>
	<packaging>pom</packaging>
	<version>0.3.0</version>
	<version>0.3.0-feature-corsAllowed</version>
	<name>Time series</name>

	<properties>
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
	<parent>
		<groupId>es.redmic.time-series</groupId>
		<artifactId>time-series</artifactId>
		<version>0.3.0</version>
		<version>0.3.0-feature-corsAllowed</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
+34 −0
Original line number Diff line number Diff line
package es.redmic.timeseriescommands.config;

/*-
 * #%L
 * Time series commands
 * %%
 * Copyright (C) 2019 REDMIC Project / Server
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

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 CorsConfiguration implements WebMvcConfigurer {

	@Override
	public void addCorsMappings(CorsRegistry registry) {
		registry.addMapping("/**").allowedMethods("GET", "PUT", "POST", "DELETE");
	}
}
+2 −0
Original line number Diff line number Diff line
@@ -38,6 +38,8 @@ public class Oauth2SecurityConfiguration {
		public void configure(HttpSecurity http) throws Exception {
			// @formatter:off
			
			http.cors();
			
			http.anonymous().and().authorizeRequests()
				.antMatchers(HttpMethod.GET, "/actuator/**").permitAll();
			
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
	<parent>
		<groupId>es.redmic.time-series</groupId>
		<artifactId>time-series</artifactId>
		<version>0.3.0</version>
		<version>0.3.0-feature-corsAllowed</version>
	</parent>

	<modelVersion>4.0.0</modelVersion>
Loading