Commit 98f7cd63 authored by Noel Alonso's avatar Noel Alonso
Browse files

Cambia configuración de seguridad

parent 6247c83f
Loading
Loading
Loading
Loading
+31 −43
Original line number Diff line number Diff line
@@ -11,12 +11,9 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.R
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;

@Configuration
public class Oauth2SecurityConfiguration {

@Configuration
@EnableResourceServer
	protected static class ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
public class Oauth2SecurityConfiguration extends ResourceServerConfigurerAdapter {

	private static final String SPARKLR_RESOURCE_ID = "sparklr";

@@ -46,14 +43,5 @@ public class Oauth2SecurityConfiguration {
	public void configure(HttpSecurity http) throws Exception {

		http.anonymous().and().authorizeRequests().antMatchers(HttpMethod.GET, "/user/actuator/**").permitAll();

			http.authorizeRequests().antMatchers("/**/ingest/**")
					.access("#oauth2.hasScope('read') or #oauth2.hasScope('write') and"
							+ " hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_OAG', 'ROLE_COLLABORATOR')");

			http.authorizeRequests().antMatchers("/**/report/**")
					.access("#oauth2.hasScope('read') or #oauth2.hasScope('write') and"
							+ " hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_OAG', 'ROLE_COLLABORATOR', 'ROLE_USER')");
		}
	}
}
+3 −5
Original line number Diff line number Diff line
package es.redmic.socket.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessageType;
import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry;
import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer;

@@ -11,10 +10,9 @@ public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBro
	@Override
	protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) {

		messages.simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.UNSUBSCRIBE, SimpMessageType.DISCONNECT)
				.permitAll();

		messages.anyMessage().authenticated();
		messages.simpDestMatchers("/socket/**")
				.hasAnyRole("ROLE_ADMINISTRATOR", "ROLE_OAG", "ROLE_COLLABORATOR", "ROLE_USER").anyMessage()
				.authenticated();
	}

	@Override