Loading src/main/java/es/redmic/socket/config/Oauth2SecurityConfiguration.java +31 −43 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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')"); } } } src/main/java/es/redmic/socket/config/WebSocketSecurityConfig.java +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; Loading @@ -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 Loading Loading
src/main/java/es/redmic/socket/config/Oauth2SecurityConfiguration.java +31 −43 Original line number Diff line number Diff line Loading @@ -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"; Loading Loading @@ -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')"); } } }
src/main/java/es/redmic/socket/config/WebSocketSecurityConfig.java +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; Loading @@ -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 Loading