Commit d95f6867 authored by Daniel Gerhardt's avatar Daniel Gerhardt Committed by Tom Käsler

Only use Spring's auto configuration for Actuator

An `AutoConfigurationImportFilter` has been implemented to filter auto
configuration classes by package name. Only classes needed for Actuator
are selected.

With this change Spring does no longer create beans for services that
are disabled. This solves problems with Actuator's health endpoint
reporting "DOWN" for those services.

An LdapTemplate bean is conditionally registered which was previously
handled by auto configuration.

Fixes #57.
parent 22341041
* 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
* 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 <>.
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[] {
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 -> 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.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
......@@ -105,9 +103,7 @@ import de.thm.arsnova.websocket.ArsnovaSocketioServerImpl;
@EnableAsync(mode = AdviceMode.ASPECTJ)
@EnableAutoConfiguration(exclude = {
@EnableCaching(mode = AdviceMode.ASPECTJ)
......@@ -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;
......@@ -467,6 +468,15 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new CustomLdapUserDetailsMapper(ldapProperties.getUserIdAttribute());
name = "ldap[0].enabled",
prefix = AuthenticationProviderProperties.PREFIX,
havingValue = "true")
public LdapTemplate ldapTemplate() {
return new LdapTemplate(ldapContextSource());
// CAS Authentication Configuration
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