Commit c12bf9b8 authored by ipatini's avatar ipatini
Browse files

EMS: Control Service: Added 'ControlServiceProperties.AuthorizationProperties'...

EMS: Control Service: Added 'ControlServiceProperties.AuthorizationProperties' inner class, and moved WebMvcConfig settings into it.
parent 4cd338e9
......@@ -19,6 +19,8 @@ import org.springframework.context.annotation.PropertySource;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Min;
import java.util.Collections;
import java.util.List;
@Slf4j
@Data
......@@ -76,10 +78,18 @@ public class ControlServiceProperties {
private KeystoreAndCertificateProperties ssl;
private TaskSchedulerProperties taskScheduler = new TaskSchedulerProperties();
private AuthorizationProperties authorization = new AuthorizationProperties();
@Data
public static class TaskSchedulerProperties {
@Min(1)
private int threadPoolSize = 2;
}
@Data
public static class AuthorizationProperties {
private boolean enabled = true;
private List<String> pathsProtected = Collections.emptyList();
private List<String> pathsExcluded = Collections.emptyList();
}
}
......@@ -9,12 +9,12 @@
package eu.melodic.event.control.webconf;
import eu.melodic.event.control.properties.ControlServiceProperties;
import eu.melodic.security.authorization.client.AuthorizationServiceTomcatInterceptor;
import eu.melodic.security.authorization.util.properties.AuthorizationServiceClientProperties;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
......@@ -39,18 +39,16 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Autowired
private AuthorizationServiceClientProperties authProperties;
@Autowired
private ControlServiceProperties controlServiceProperties;
@Autowired
private ApplicationContext applicationContext;
@Value("${authorization.enabled:true}")
private boolean authEnabled;
@Value("${authorization.paths-protected:}")
private String[] authPathsProtected;
@Value("${authorization.paths-excluded:}")
private String[] authPathsExcluded;
@Override
public void addInterceptors(InterceptorRegistry registry) {
// Add authorization interceptor (if configured)
boolean authEnabled = controlServiceProperties.getAuthorization().isEnabled();
String[] authPathsProtected = controlServiceProperties.getAuthorization().getPathsProtected().toArray(new String[0]);
String[] authPathsExcluded = controlServiceProperties.getAuthorization().getPathsExcluded().toArray(new String[0]);
if (!authEnabled || authProperties.getPdp().isDisabled()) {
log.warn("WebMvcConfig.addInterceptors(): Authorization check is disabled");
} else {
......
Supports Markdown
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