-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from ScorpioBroker/ldlibchange
Ldlibchange
- Loading branch information
Showing
492 changed files
with
31,281 additions
and
28,979 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 8 additions & 114 deletions
122
AllInOneRunner/src/main/java/eu/neclab/ngsildbroker/runner/Runner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,127 +1,21 @@ | ||
package eu.neclab.ngsildbroker.runner; | ||
|
||
import org.apache.catalina.connector.Connector; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; | ||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | ||
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.ComponentScan.Filter; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.security.web.firewall.DefaultHttpFirewall; | ||
import org.springframework.security.web.firewall.HttpFirewall; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
import org.springframework.context.annotation.FilterType; | ||
import org.springframework.context.annotation.Profile; | ||
import eu.neclab.ngsildbroker.entityhandler.EntityHandler; | ||
import eu.neclab.ngsildbroker.historymanager.HistoryHandler; | ||
import eu.neclab.ngsildbroker.queryhandler.QueryHandler; | ||
import eu.neclab.ngsildbroker.registry.subscriptionmanager.RegistrySubscriptionHandler; | ||
import eu.neclab.ngsildbroker.registryhandler.RegistryHandler; | ||
import eu.neclab.ngsildbroker.subscriptionmanager.SubscriptionHandler; | ||
|
||
@SpringBootApplication | ||
@ComponentScan(basePackages = { | ||
"eu.neclab.ngsildbroker.*" }, excludeFilters = @Filter(type = FilterType.REGEX, pattern = { | ||
"eu.neclab.ngsildbroker.commons.*" })) | ||
//@Import(KafkaConfig.class) | ||
public class Runner { | ||
|
||
public static void main(String[] args) throws Exception { | ||
System.setProperty("org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH", "true"); | ||
SpringApplication.run(Runner.class, args); | ||
SpringApplication.run(new Class[] { RegistryHandler.class, HistoryHandler.class, QueryHandler.class, | ||
RegistrySubscriptionHandler.class, EntityHandler.class, SubscriptionHandler.class }, args); | ||
} | ||
|
||
@Value("${gateway.enablecors:false}") | ||
boolean enableCors; | ||
@Value("${gateway.enablecors.allowall:false}") | ||
boolean allowAllCors; | ||
|
||
@Value("${gateway.enablecors.allowedorigin:null}") | ||
String allowedOrigin; | ||
|
||
@Value("${gateway.enablecors.allowedheader:null}") | ||
String allowedHeader; | ||
|
||
@Value("${gateway.enablecors.allowallmethods:false}") | ||
boolean allowAllCorsMethods; | ||
|
||
@Value("${gateway.enablecors.allowedmethods:null}") | ||
String allowedMethods; | ||
|
||
@Bean | ||
public CorsFilter corsFilter() { | ||
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
if (!enableCors) { | ||
return new CorsFilter(source); | ||
} | ||
final CorsConfiguration config = new CorsConfiguration(); | ||
if (allowAllCors) { | ||
config.setAllowCredentials(true); | ||
config.addAllowedOrigin("*"); | ||
config.addAllowedHeader("*"); | ||
config.addAllowedMethod(HttpMethod.DELETE); | ||
config.addAllowedMethod(HttpMethod.POST); | ||
config.addAllowedMethod(HttpMethod.GET); | ||
config.addAllowedMethod(HttpMethod.OPTIONS); | ||
config.addAllowedMethod(HttpMethod.PATCH); | ||
config.addAllowedMethod(HttpMethod.PUT); | ||
config.addAllowedMethod(HttpMethod.HEAD); | ||
config.addAllowedMethod(HttpMethod.TRACE); | ||
source.registerCorsConfiguration("/**", config); | ||
} else { | ||
if (allowedOrigin != null) { | ||
for (String origin : allowedOrigin.split(",")) { | ||
config.addAllowedOrigin(origin); | ||
} | ||
|
||
} | ||
if (allowedHeader != null) { | ||
for (String header : allowedHeader.split(",")) { | ||
config.addAllowedHeader(header); | ||
} | ||
} | ||
if (allowAllCorsMethods) { | ||
config.addAllowedMethod(HttpMethod.DELETE); | ||
config.addAllowedMethod(HttpMethod.POST); | ||
config.addAllowedMethod(HttpMethod.GET); | ||
config.addAllowedMethod(HttpMethod.OPTIONS); | ||
config.addAllowedMethod(HttpMethod.PATCH); | ||
config.addAllowedMethod(HttpMethod.PUT); | ||
config.addAllowedMethod(HttpMethod.HEAD); | ||
config.addAllowedMethod(HttpMethod.TRACE); | ||
} else { | ||
if (allowedMethods != null) { | ||
for (String method : allowedMethods.split(",")) { | ||
config.addAllowedMethod(method); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return new CorsFilter(source); | ||
} | ||
|
||
@Profile({ "!docker", "!eureka" }) | ||
@Bean | ||
public HttpFirewall allowUrlEncodedSlashHttpFirewall() { | ||
DefaultHttpFirewall firewall = new DefaultHttpFirewall(); | ||
firewall.setAllowUrlEncodedSlash(true); | ||
return firewall; | ||
} | ||
|
||
@Profile({ "!docker", "!eureka" }) | ||
@Bean | ||
public ConfigurableServletWebServerFactory webServerFactory() { | ||
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); | ||
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { | ||
@Override | ||
public void customize(Connector connector) { | ||
connector.setProperty("relaxedQueryChars", "|{}[]"); | ||
// connector.setProperty("encodedSolidusHandling", "passthrough"); | ||
// Doesn't do anything | ||
} | ||
}); | ||
return factory; | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
...neRunner/src/main/java/eu/neclab/ngsildbroker/runner/security/SiteSecurityConfigurer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.