Commit 32c1d881 authored by Selvakumar Kamatchinathan's avatar Selvakumar Kamatchinathan
Browse files

spring boot 2.0.0

parent cb0dcc0f
......@@ -19,13 +19,14 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -88,22 +89,22 @@
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-data-rest</artifactId>
<version>2.8.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.8.0</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
......@@ -139,4 +140,12 @@
</plugins>
</build>
<repositories>
<repository>
<id>JFrog</id>
<name>JFrog Snapshot Repository</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</repository>
</repositories>
</project>
......@@ -20,7 +20,7 @@ package uk.ac.ebi.ampt2d.registry;
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 {
......
......@@ -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.data.rest.configuration.SpringDataRestConf
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 class SwaggerConfiguration {
}
private Predicate<String> 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() {
......
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
......
......@@ -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.OAuth2Request;
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 @@ import java.util.Set;
@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 @@ public class OAuthHelper extends AuthorizationServerConfigurerAdapter {
ClientDetails client = clientDetailsService.loadClientByClientId(clientId);
Map<String, Object> clientEmailMap = new HashMap<>();
clientEmailMap.put("email", clientId);
Collection<GrantedAuthority> authorities = authoritiesExtractor(registryUserRepository).extractAuthorities(clientEmailMap);
Collection<GrantedAuthority> authorities = authoritiesExtractor.extractAuthorities(clientEmailMap);
Set<String> resourceIds = client.getResourceIds();
Set<String> scopes = client.getScope();
......@@ -97,9 +96,4 @@ public class OAuthHelper extends AuthorizationServerConfigurerAdapter {
.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
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
......
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="root" level="INFO"/>
</configuration>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment