Fixed property bean setup
This commit is contained in:
@@ -9,13 +9,11 @@
|
|||||||
package org.eclipse.hawkbit.autoconfigure.scheduling;
|
package org.eclipse.hawkbit.autoconfigure.scheduling;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties for the async configurer.
|
* Properties for the async configurer.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@ConfigurationProperties("hawkbit.threadpool")
|
@ConfigurationProperties("hawkbit.threadpool")
|
||||||
public class AsyncConfigurerThreadpoolProperties {
|
public class AsyncConfigurerThreadpoolProperties {
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class SecurityManagedConfiguration {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
@Autowired
|
@Autowired
|
||||||
private DdiSecurityProperties securityConfiguration;
|
private DdiSecurityProperties ddiSecurityConfiguration;
|
||||||
@Autowired
|
@Autowired
|
||||||
private org.springframework.boot.autoconfigure.security.SecurityProperties springSecurityProperties;
|
private org.springframework.boot.autoconfigure.security.SecurityProperties springSecurityProperties;
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ public class SecurityManagedConfiguration {
|
|||||||
final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource();
|
final ControllerTenantAwareAuthenticationDetailsSource authenticationDetailsSource = new ControllerTenantAwareAuthenticationDetailsSource();
|
||||||
|
|
||||||
final HttpControllerPreAuthenticatedSecurityHeaderFilter securityHeaderFilter = new HttpControllerPreAuthenticatedSecurityHeaderFilter(
|
final HttpControllerPreAuthenticatedSecurityHeaderFilter securityHeaderFilter = new HttpControllerPreAuthenticatedSecurityHeaderFilter(
|
||||||
securityConfiguration.getRp().getCnHeader(), securityConfiguration.getRp().getSslIssuerHashHeader(),
|
ddiSecurityConfiguration.getRp().getCnHeader(), ddiSecurityConfiguration.getRp().getSslIssuerHashHeader(),
|
||||||
systemManagement, tenantAware);
|
systemManagement, tenantAware);
|
||||||
securityHeaderFilter.setAuthenticationManager(authenticationManager());
|
securityHeaderFilter.setAuthenticationManager(authenticationManager());
|
||||||
securityHeaderFilter.setCheckForPrincipalChanges(true);
|
securityHeaderFilter.setCheckForPrincipalChanges(true);
|
||||||
@@ -150,7 +150,7 @@ public class SecurityManagedConfiguration {
|
|||||||
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (securityConfiguration.getAuthentication().getAnonymous().isEnabled()) {
|
if (ddiSecurityConfiguration.getAuthentication().getAnonymous().isEnabled()) {
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
"******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************");
|
||||||
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter(
|
||||||
@@ -181,7 +181,7 @@ public class SecurityManagedConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(
|
auth.authenticationProvider(
|
||||||
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRp().getTrustedIPs()));
|
new PreAuthTokenSourceTrustAuthenticationProvider(ddiSecurityConfiguration.getRp().getTrustedIPs()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,7 +444,7 @@ public class SecurityManagedConfiguration {
|
|||||||
public static class IdRestSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
public static class IdRestSecurityConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DdiSecurityProperties securityConfiguration;
|
private DdiSecurityProperties ddiSecurityConfiguration;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
@Qualifier(CacheConstants.DOWNLOAD_ID_CACHE)
|
||||||
@@ -467,7 +467,7 @@ public class SecurityManagedConfiguration {
|
|||||||
@Override
|
@Override
|
||||||
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
protected void configure(final AuthenticationManagerBuilder auth) throws Exception {
|
||||||
auth.authenticationProvider(
|
auth.authenticationProvider(
|
||||||
new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRp().getTrustedIPs()));
|
new PreAuthTokenSourceTrustAuthenticationProvider(ddiSecurityConfiguration.getRp().getTrustedIPs()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,4 @@ org.eclipse.hawkbit.autoconfigure.eventbus.EventBusAutoConfiguration,\
|
|||||||
org.eclipse.hawkbit.autoconfigure.scheduling.AsyncConfigurerAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.scheduling.AsyncConfigurerAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.cache.RedisAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.cache.RedisAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.scheduling.ExecutorAutoConfiguration,\
|
org.eclipse.hawkbit.autoconfigure.scheduling.ExecutorAutoConfiguration,\
|
||||||
org.eclipse.hawkbit.autoconfigure.conf.ControllerPollAutoConfiguration,\
|
|
||||||
org.eclipse.hawkbit.autoconfigure.amqp.AmqpAutoConfiguration
|
org.eclipse.hawkbit.autoconfigure.amqp.AmqpAutoConfiguration
|
||||||
|
|||||||
@@ -29,11 +29,10 @@ flyway.initOnMigrate=true
|
|||||||
flyway.sqlMigrationSuffix=${spring.jpa.database}.sql
|
flyway.sqlMigrationSuffix=${spring.jpa.database}.sql
|
||||||
|
|
||||||
# Vaadin Servlet
|
# Vaadin Servlet
|
||||||
vaadin.static.servlet.productionMode=true
|
|
||||||
vaadin.servlet.productionMode=true
|
vaadin.servlet.productionMode=true
|
||||||
vaadin.servlet.urlMapping=/UI/*
|
vaadin.servlet.urlMapping=/UI/*
|
||||||
vaadin.servlet.params.heartbeatInterval=60
|
vaadin.servlet.heartbeatInterval=60
|
||||||
vaadin.servlet.params.closeIdleSessions=false
|
vaadin.servlet.closeIdleSessions=false
|
||||||
|
|
||||||
# Spring MVC
|
# Spring MVC
|
||||||
spring.mvc.favicon.enabled=false
|
spring.mvc.favicon.enabled=false
|
||||||
|
|||||||
@@ -9,13 +9,11 @@
|
|||||||
package org.eclipse.hawkbit;
|
package org.eclipse.hawkbit;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Properties for the server e.g. the server's URL which must be configured.
|
* Properties for the server e.g. the server's URL which must be configured.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@ConfigurationProperties("hawkbit.server")
|
@ConfigurationProperties("hawkbit.server")
|
||||||
public class HawkbitServerProperties {
|
public class HawkbitServerProperties {
|
||||||
/**
|
/**
|
||||||
@@ -31,7 +29,7 @@ public class HawkbitServerProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build information of the hawkBit instance. Influeneced by maven.
|
* Build information of the hawkBit instance. Influenced by maven.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static class Build {
|
public static class Build {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class AmqpControllerAuthentfication {
|
|||||||
private TenantAware tenantAware;
|
private TenantAware tenantAware;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DdiSecurityProperties secruityProperties;
|
private DdiSecurityProperties ddiSecruityProperties;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -78,7 +78,7 @@ public class AmqpControllerAuthentfication {
|
|||||||
filterChain.add(gatewaySecurityTokenFilter);
|
filterChain.add(gatewaySecurityTokenFilter);
|
||||||
|
|
||||||
final ControllerPreAuthenticatedSecurityHeaderFilter securityHeaderFilter = new ControllerPreAuthenticatedSecurityHeaderFilter(
|
final ControllerPreAuthenticatedSecurityHeaderFilter securityHeaderFilter = new ControllerPreAuthenticatedSecurityHeaderFilter(
|
||||||
secruityProperties.getRp().getCnHeader(), secruityProperties.getRp().getSslIssuerHashHeader(),
|
ddiSecruityProperties.getRp().getCnHeader(), ddiSecruityProperties.getRp().getSslIssuerHashHeader(),
|
||||||
systemManagement, tenantAware);
|
systemManagement, tenantAware);
|
||||||
filterChain.add(securityHeaderFilter);
|
filterChain.add(securityHeaderFilter);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ public class AmqpControllerAuthentfication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSecruityProperties(final DdiSecurityProperties secruityProperties) {
|
public void setSecruityProperties(final DdiSecurityProperties secruityProperties) {
|
||||||
this.secruityProperties = secruityProperties;
|
this.ddiSecruityProperties = secruityProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSystemManagement(final SystemManagement systemManagement) {
|
public void setSystemManagement(final SystemManagement systemManagement) {
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests generate the http download url")
|
@Description("Tests the generation of http download url.")
|
||||||
public void testHttpUrl() {
|
public void testHttpUrl() {
|
||||||
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.HTTP);
|
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.HTTP);
|
||||||
assertEquals("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
assertEquals("http://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||||
@@ -59,7 +59,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests generate the https download url")
|
@Description("Tests the generation of https download url.")
|
||||||
public void testHttpsUrl() {
|
public void testHttpsUrl() {
|
||||||
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.HTTPS);
|
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.HTTPS);
|
||||||
assertEquals("https://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
assertEquals("https://localhost/" + tenantAware.getCurrentTenant() + "/controller/v1/" + controllerId
|
||||||
@@ -68,7 +68,7 @@ public class PropertyBasedArtifactUrlHandlerTest extends AbstractIntegrationTest
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Description("Tests generate the coap download url")
|
@Description("Tests the generation of coap download url.")
|
||||||
public void testCoapUrl() {
|
public void testCoapUrl() {
|
||||||
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.COAP);
|
final String url = urlHandlerProperties.getUrl(controllerId, localArtifact, Artifact.UrlProtocol.COAP);
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,13 @@ import org.eclipse.hawkbit.cache.TenantAwareCacheManager;
|
|||||||
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
import org.eclipse.hawkbit.repository.model.helper.EventBusHolder;
|
||||||
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator;
|
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator;
|
||||||
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator.DatabaseCleanupUtil;
|
import org.eclipse.hawkbit.repository.utils.RepositoryDataGenerator.DatabaseCleanupUtil;
|
||||||
|
import org.eclipse.hawkbit.security.DdiSecurityProperties;
|
||||||
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
|
import org.eclipse.hawkbit.security.SecurityContextTenantAware;
|
||||||
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
|
import org.eclipse.hawkbit.security.SpringSecurityAuditorAware;
|
||||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||||
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
|
||||||
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
|
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cache.Cache;
|
import org.springframework.cache.Cache;
|
||||||
import org.springframework.cache.guava.GuavaCacheManager;
|
import org.springframework.cache.guava.GuavaCacheManager;
|
||||||
import org.springframework.context.annotation.AdviceMode;
|
import org.springframework.context.annotation.AdviceMode;
|
||||||
@@ -45,8 +47,7 @@ import com.mongodb.MongoClientOptions;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true)
|
@EnableGlobalMethodSecurity(prePostEnabled = true, mode = AdviceMode.ASPECTJ, proxyTargetClass = true, securedEnabled = true)
|
||||||
// @EnableConfigurationProperties({ DdiSecurityProperties.class,
|
@EnableConfigurationProperties({ DdiSecurityProperties.class, ControllerPollProperties.class })
|
||||||
// ControllerPollProperties.class })
|
|
||||||
@Profile("test")
|
@Profile("test")
|
||||||
public class TestConfiguration implements AsyncConfigurer {
|
public class TestConfiguration implements AsyncConfigurer {
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,10 @@ package org.eclipse.hawkbit.security;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The common properties for DDI security.
|
* The common properties for DDI security.
|
||||||
*/
|
*/
|
||||||
@Component
|
|
||||||
@ConfigurationProperties("hawkbit.server.ddi.security")
|
@ConfigurationProperties("hawkbit.server.ddi.security")
|
||||||
public class DdiSecurityProperties {
|
public class DdiSecurityProperties {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user