Commit 7ae685ce authored by Tom Käsler's avatar Tom Käsler

Merge branch 'refac-actuator-autoconfig' into 'master'

Only use Spring's auto configuration for Actuator

Closes #57

See merge request arsnova/arsnova-backend!186
parents 22341041 d95f6867
/*
* This file is part of ARSnova Backend.
* Copyright (C) 2012-2019 The ARSnova Team and Contributors
*
* ARSnova Backend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ARSnova Backend is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.thm.arsnova.config;
import java.util.Arrays;
import java.util.List;
import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;
import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
/**
* An {@link AutoConfigurationImportFilter} that only selects AutoConfiguration
* classes needed for Spring Actuator.
*
* @author Daniel Gerhardt
*/
public class ActuatorAutoConfigurationFilter implements AutoConfigurationImportFilter {
private static final List<String> actuatorClassesPrefixes = Arrays.asList(new String[] {
"org.springframework.boot.actuate.autoconfigure.",
"org.springframework.boot.autoconfigure.web.servlet."});
@Override
public boolean[] match(final String[] autoConfigurationClasses,
final AutoConfigurationMetadata autoConfigurationMetadata) {
final boolean[] results = new boolean[autoConfigurationClasses.length];
for (int i = 0; i < results.length; i++) {
results[i] = autoConfigurationClasses[i] != null && checkPrefix(autoConfigurationClasses[i]);
}
return results;
}
private boolean checkPrefix(final String className) {
return actuatorClassesPrefixes.stream().anyMatch(p -> className.startsWith(p));
}
}
......@@ -34,8 +34,6 @@ import org.springframework.boot.actuate.endpoint.http.ActuatorMediaType;
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter;
import org.springframework.boot.actuate.metrics.web.servlet.WebMvcTagsProvider;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
......@@ -105,9 +103,7 @@ import de.thm.arsnova.websocket.ArsnovaSocketioServerImpl;
"de.thm.arsnova.websocket.handler"})
@Configuration
@EnableAsync(mode = AdviceMode.ASPECTJ)
@EnableAutoConfiguration(exclude = {
DataSourceAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class})
@EnableAutoConfiguration
@EnableCaching(mode = AdviceMode.ASPECTJ)
@EnableScheduling
@EnableSpringConfigured
......
......@@ -51,6 +51,7 @@ import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;
import org.springframework.security.access.intercept.RunAsManager;
import org.springframework.security.access.intercept.RunAsManagerImpl;
......@@ -467,6 +468,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new CustomLdapUserDetailsMapper(ldapProperties.getUserIdAttribute());
}
@Bean
@ConditionalOnProperty(
name = "ldap[0].enabled",
prefix = AuthenticationProviderProperties.PREFIX,
havingValue = "true")
public LdapTemplate ldapTemplate() {
return new LdapTemplate(ldapContextSource());
}
// CAS Authentication Configuration
@Bean
......
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
de.thm.arsnova.config.ActuatorAutoConfigurationFilter
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