diff --git a/pom.xml b/pom.xml
index 560a63c..a3b3e40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,13 +19,14 @@
org.springframework.boot
spring-boot-starter-parent
- 1.5.10.RELEASE
+ 2.0.0.RELEASE
- org.springframework.security.oauth
- spring-security-oauth2
+ org.springframework.security.oauth.boot
+ spring-security-oauth2-autoconfigure
+ 2.0.0.RELEASE
org.springframework.boot
@@ -88,22 +89,22 @@
io.springfox
springfox-swagger2
- 2.8.0
+ 3.0.0-SNAPSHOT
io.springfox
springfox-swagger-ui
- 2.8.0
+ 3.0.0-SNAPSHOT
io.springfox
springfox-data-rest
- 2.8.0
+ 3.0.0-SNAPSHOT
io.springfox
springfox-bean-validators
- 2.8.0
+ 3.0.0-SNAPSHOT
@@ -139,4 +140,12 @@
+
+
+ JFrog
+ JFrog Snapshot Repository
+ http://oss.jfrog.org/artifactory/oss-snapshot-local/
+
+
+
diff --git a/src/main/java/uk/ac/ebi/ampt2d/registry/PropertyRegistryServiceApplication.java b/src/main/java/uk/ac/ebi/ampt2d/registry/PropertyRegistryServiceApplication.java
index 6218e79..0bdf6c4 100644
--- a/src/main/java/uk/ac/ebi/ampt2d/registry/PropertyRegistryServiceApplication.java
+++ b/src/main/java/uk/ac/ebi/ampt2d/registry/PropertyRegistryServiceApplication.java
@@ -20,7 +20,7 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
-import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class PropertyRegistryServiceApplication extends SpringBootServletInitializer {
diff --git a/src/main/java/uk/ac/ebi/ampt2d/registry/config/SwaggerConfiguration.java b/src/main/java/uk/ac/ebi/ampt2d/registry/config/SwaggerConfiguration.java
index 79d60fd..8646b8a 100644
--- a/src/main/java/uk/ac/ebi/ampt2d/registry/config/SwaggerConfiguration.java
+++ b/src/main/java/uk/ac/ebi/ampt2d/registry/config/SwaggerConfiguration.java
@@ -18,8 +18,6 @@
package uk.ac.ebi.ampt2d.registry.config;
import com.fasterxml.classmate.TypeResolver;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -43,15 +41,16 @@
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger.web.UiConfiguration;
import springfox.documentation.swagger.web.UiConfigurationBuilder;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
+import java.util.function.Predicate;
import static springfox.documentation.schema.AlternateTypeRules.newRule;
@Configuration
-@EnableSwagger2
+@EnableSwagger2WebMvc
@Import({SpringDataRestConfiguration.class, BeanValidatorPluginsConfiguration.class})
public class SwaggerConfiguration {
@@ -85,12 +84,10 @@ public Docket propertyRegistryApi() {
}
private Predicate getScanRestServicesPathPredicate() {
- return Predicates.and(
- Predicates.not(PathSelectors.regex("/actuator.*")), // Hide spring-actuator
- Predicates.not(PathSelectors.regex("/error.*")), // Hide spring-data error
- Predicates.not(PathSelectors.regex("/profile.*")),// Hide spring-data profile
- Predicates.not(PathSelectors.regex("/users.*")) // Hide user-profile
- );
+ return PathSelectors.regex(".*/actuator.*") // Hide spring-actuator
+ .or(PathSelectors.regex(".*/error.*")) // Hide spring-data error
+ .or(PathSelectors.regex(".*/profile.*")) // Hide spring-data profile
+ .or(PathSelectors.regex(".*/users.*")).negate(); // Hide users
}
private ApiInfo getApiInfo() {
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 8494936..ed34f69 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,14 +1,10 @@
spring.application.name=ampt2d-property-registry
# Bean jmx domain for actuator when using multiple applications with tomcat.
-endpoints.jmx.domain=ampt2d-property-registry
spring.jmx.default-domain=ampt2d-property-registry
-management.security.enabled=false
-management.context-path=/actuator
management.endpoint.health.show-details=always
-endpoints.health.sensitive=false
spring.datasource.url=@ampt2d-property-registry-db.url@
spring.datasource.username=@ampt2d-property-registry-db.username@
@@ -19,7 +15,6 @@ spring.jpa.generate-ddl=true
security.enabled=true
security.oauth2.resource.userInfoUri=https://www.googleapis.com/userinfo/v2/me
-security.oauth2.resource.filter-order=3
spring.mail.host=@smtp-host@
spring.mail.port=587
diff --git a/src/test/java/uk/ac/ebi/ampt2d/registry/OAuthHelper.java b/src/test/java/uk/ac/ebi/ampt2d/registry/OAuthHelper.java
index 7cf2f31..e5902e2 100644
--- a/src/test/java/uk/ac/ebi/ampt2d/registry/OAuthHelper.java
+++ b/src/test/java/uk/ac/ebi/ampt2d/registry/OAuthHelper.java
@@ -18,8 +18,8 @@
package uk.ac.ebi.ampt2d.registry;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.security.oauth2.resource.AuthoritiesExtractor;
-import org.springframework.context.annotation.Bean;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
@@ -34,8 +34,6 @@
import org.springframework.security.oauth2.provider.token.AuthorizationServerTokenServices;
import org.springframework.stereotype.Component;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
-import uk.ac.ebi.ampt2d.registry.config.security.CustomAuthoritiesExtractor;
-import uk.ac.ebi.ampt2d.registry.repositories.RegistryUserRepository;
import java.io.Serializable;
import java.util.Collection;
@@ -46,6 +44,7 @@
@Component
@EnableAuthorizationServer
+@ConditionalOnProperty(name = "security.enabled", havingValue = "true")
public class OAuthHelper extends AuthorizationServerConfigurerAdapter {
@Autowired
@@ -55,7 +54,7 @@ public class OAuthHelper extends AuthorizationServerConfigurerAdapter {
private ClientDetailsService clientDetailsService;
@Autowired
- private RegistryUserRepository registryUserRepository;
+ private AuthoritiesExtractor authoritiesExtractor;
public RequestPostProcessor bearerToken(final String clientid) {
return mockRequest -> {
@@ -69,7 +68,7 @@ private OAuth2AccessToken createAccessToken(final String clientId) {
ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
Map clientEmailMap = new HashMap<>();
clientEmailMap.put("email", clientId);
- Collection authorities = authoritiesExtractor(registryUserRepository).extractAuthorities(clientEmailMap);
+ Collection authorities = authoritiesExtractor.extractAuthorities(clientEmailMap);
Set resourceIds = client.getResourceIds();
Set scopes = client.getScope();
@@ -97,9 +96,4 @@ public void configure(final ClientDetailsServiceConfigurer clients) throws Excep
.withClient("testUser@gmail.com").and()
.withClient("testAdmin@gmail.com");
}
-
- @Bean
- public AuthoritiesExtractor authoritiesExtractor(RegistryUserRepository registryUserRepository) {
- return new CustomAuthoritiesExtractor(registryUserRepository);
- }
}
\ No newline at end of file
diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties
index 95d207a..3a5a31f 100644
--- a/src/test/resources/application.properties
+++ b/src/test/resources/application.properties
@@ -1,23 +1,16 @@
spring.application.name=ampt2d-property-registry
# Bean jmx domain for actuator when using multiple applications with tomcat.
-endpoints.jmx.domain=ampt2d-property-registry
spring.jmx.default-domain=ampt2d-property-registry
-management.security.enabled=false
-
-management.context-path=/actuator
management.endpoint.health.show-details=always
-endpoints.health.sensitive=false
registry.protocols=http
-
spring.jpa.hibernate.ddl-auto=create
spring.mail.port=587
spring.mail.test-connection=false
spring.mail.properties.mail.smtp.auth=false
spring.mail.properties.mail.smtp.ssl.enable=false
-
mail.from=user@domain
mail.to=user@domain
mail.subject=AMP-T2D Registry Update
diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..abb06b5
--- /dev/null
+++ b/src/test/resources/logback-test.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file