Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
${{ runner.os }}-maven-
${{ runner.os }}-
- name: Run maven build
run: mvn install
run: mvn install -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
${{ runner.os }}-

- name: Run maven build
run: mvn verify -s .github/workflows/settings.xml
run: mvn verify -s .github/workflows/settings.xml -PprettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
- name: Sonar Scan
env:
SONAR_TOKEN: ${{ secrets.ENTUR_SONAR_PASSWORD }}
Expand All @@ -66,4 +66,4 @@ jobs:
with:
push_to_repo: true
snapshot: false
next_version: ''
next_version: ''
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
@Configuration
public class LoaderConfiguration {

@Bean
public Loader loader(LoaderProperties properties) {
return new Loader(
properties.getHttp().getMaxTotalConnections(),
properties.getHttp().getMaxConnectionsPerRoute(),
properties.getHttp().getConnectTimeoutSeconds(),
properties.getHttp().getResponseTimeoutSeconds(),
properties.getThreadPool().getSize(),
properties.getHttp().getHeaders()
);
}
@Bean
public Loader loader(LoaderProperties properties) {
return new Loader(
properties.getHttp().getMaxTotalConnections(),
properties.getHttp().getMaxConnectionsPerRoute(),
properties.getHttp().getConnectTimeoutSeconds(),
properties.getHttp().getResponseTimeoutSeconds(),
properties.getThreadPool().getSize(),
properties.getHttp().getHeaders()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,92 +20,93 @@

package org.entur.gbfs.validator.api.handler;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "loader")
public class LoaderProperties {

private Http http = new Http();
private ThreadPool threadPool = new ThreadPool();
private Http http = new Http();
private ThreadPool threadPool = new ThreadPool();

public Http getHttp() {
return http;
}
public Http getHttp() {
return http;
}

public void setHttp(Http http) {
this.http = http;
}
public void setHttp(Http http) {
this.http = http;
}

public ThreadPool getThreadPool() {
return threadPool;
}
public ThreadPool getThreadPool() {
return threadPool;
}

public void setThreadPool(ThreadPool threadPool) {
this.threadPool = threadPool;
}
public void setThreadPool(ThreadPool threadPool) {
this.threadPool = threadPool;
}

public static class Http {
private int maxTotalConnections = 50;
private int maxConnectionsPerRoute = 20;
private int connectTimeoutSeconds = 5;
private int responseTimeoutSeconds = 5;
private Map<String, String> headers = new HashMap<>();
public static class Http {

public int getMaxTotalConnections() {
return maxTotalConnections;
}
private int maxTotalConnections = 50;
private int maxConnectionsPerRoute = 20;
private int connectTimeoutSeconds = 5;
private int responseTimeoutSeconds = 5;
private Map<String, String> headers = new HashMap<>();

public void setMaxTotalConnections(int maxTotalConnections) {
this.maxTotalConnections = maxTotalConnections;
}
public int getMaxTotalConnections() {
return maxTotalConnections;
}

public int getMaxConnectionsPerRoute() {
return maxConnectionsPerRoute;
}
public void setMaxTotalConnections(int maxTotalConnections) {
this.maxTotalConnections = maxTotalConnections;
}

public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) {
this.maxConnectionsPerRoute = maxConnectionsPerRoute;
}
public int getMaxConnectionsPerRoute() {
return maxConnectionsPerRoute;
}

public int getConnectTimeoutSeconds() {
return connectTimeoutSeconds;
}
public void setMaxConnectionsPerRoute(int maxConnectionsPerRoute) {
this.maxConnectionsPerRoute = maxConnectionsPerRoute;
}

public void setConnectTimeoutSeconds(int connectTimeoutSeconds) {
this.connectTimeoutSeconds = connectTimeoutSeconds;
}
public int getConnectTimeoutSeconds() {
return connectTimeoutSeconds;
}

public void setConnectTimeoutSeconds(int connectTimeoutSeconds) {
this.connectTimeoutSeconds = connectTimeoutSeconds;
}

public int getResponseTimeoutSeconds() {
return responseTimeoutSeconds;
}
public int getResponseTimeoutSeconds() {
return responseTimeoutSeconds;
}

public void setResponseTimeoutSeconds(int responseTimeoutSeconds) {
this.responseTimeoutSeconds = responseTimeoutSeconds;
}
public void setResponseTimeoutSeconds(int responseTimeoutSeconds) {
this.responseTimeoutSeconds = responseTimeoutSeconds;
}

public Map<String, String> getHeaders() {
return headers;
}
public Map<String, String> getHeaders() {
return headers;
}

public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
public void setHeaders(Map<String, String> headers) {
this.headers = headers;
}
}

public static class ThreadPool {
private int size = 20;
public static class ThreadPool {

public int getSize() {
return size;
}
private int size = 20;

public int getSize() {
return size;
}

public void setSize(int size) {
this.size = size;
}
public void setSize(int size) {
this.size = size;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package org.entur.gbfs.validator.api.handler;

import java.util.Arrays;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.authentication.AuthenticationManager;
Expand All @@ -31,9 +33,6 @@
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;

import java.util.Arrays;
import java.util.List;

/**
* Security configuration for the GBFS Validator API.
* Handles CORS configuration to allow cross-origin requests.
Expand All @@ -42,33 +41,34 @@
@EnableWebSecurity
public class SecurityConfig {

@Bean
public SecurityFilterChain filterChain(
HttpSecurity http
) throws Exception {
return http
.csrf(csrf -> csrf.disable())
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.build();
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http
.csrf(csrf -> csrf.disable())
.cors(cors -> cors.configurationSource(corsConfigurationSource()))
.build();
}

private CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.addAllowedOriginPattern("*");
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowedHeaders(List.of("*"));
configuration.setExposedHeaders(List.of("*"));
configuration.setAllowCredentials(false);
configuration.setMaxAge(3600L); // Cache preflight response for 1 hour
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
private CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.addAllowedOriginPattern("*");
configuration.setAllowedMethods(
Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS")
);
configuration.setAllowedHeaders(List.of("*"));
configuration.setExposedHeaders(List.of("*"));
configuration.setAllowCredentials(false);
configuration.setMaxAge(3600L); // Cache preflight response for 1 hour
UrlBasedCorsConfigurationSource source =
new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}

@Bean
public AuthenticationManager noopAuthenticationManager() {
return authentication -> {
throw new AuthenticationServiceException("Authentication is disabled");
};
}
@Bean
public AuthenticationManager noopAuthenticationManager() {
return authentication -> {
throw new AuthenticationServiceException("Authentication is disabled");
};
}
}
Loading