parent
b4391fa599
commit
0545e9c412
21
build.gradle
21
build.gradle
|
@ -1,20 +1,22 @@
|
||||||
plugins {
|
plugins {
|
||||||
id 'org.springframework.boot' version '2.7.18'
|
id 'org.springframework.boot' version '3.4.1'
|
||||||
id 'io.spring.dependency-management' version '1.1.6'
|
id 'io.spring.dependency-management' version '1.1.7'
|
||||||
id 'java'
|
id 'java'
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
group = 'eu.openaire.urls_worker'
|
group = 'eu.openaire.urls_worker'
|
||||||
version = '2.1.15'
|
version = '2.1.15'
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(17)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
maven {
|
||||||
name "d4science"
|
name = "d4science"
|
||||||
url "https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots/"
|
url = "https://maven.d4science.org/nexus/content/repositories/dnet45-snapshots/"
|
||||||
}
|
}
|
||||||
// Enable the following, in case you want to test temporal-jars.
|
// Enable the following, in case you want to test temporal-jars.
|
||||||
/*flatDir {
|
/*flatDir {
|
||||||
|
@ -23,15 +25,18 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
developmentOnly "org.springframework.boot:spring-boot-devtools"
|
//developmentOnly "org.springframework.boot:spring-boot-devtools"
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-starter-web")
|
implementation("org.springframework.boot:spring-boot-starter-web")
|
||||||
implementation("org.springframework.boot:spring-boot-starter-security")
|
implementation("org.springframework.boot:spring-boot-starter-security")
|
||||||
|
|
||||||
implementation("org.springframework.boot:spring-boot-configuration-processor")
|
implementation("org.springframework.boot:spring-boot-configuration-processor")
|
||||||
|
|
||||||
implementation("org.springframework.security:spring-security-core")
|
implementation("org.springframework.security:spring-security-core")
|
||||||
implementation("org.springframework.security:spring-security-web")
|
implementation("org.springframework.security:spring-security-web")
|
||||||
implementation("org.springframework.security:spring-security-config")
|
implementation("org.springframework.security:spring-security-config")
|
||||||
|
|
||||||
|
|
||||||
//implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' // Use this in case we use auth-tokens later on.
|
//implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.5' // Use this in case we use auth-tokens later on.
|
||||||
|
|
||||||
// Enable the validation annotations.
|
// Enable the validation annotations.
|
||||||
|
@ -45,7 +50,7 @@ dependencies {
|
||||||
exclude group: 'org.apache.commons', module: 'commons-compress'
|
exclude group: 'org.apache.commons', module: 'commons-compress'
|
||||||
}
|
}
|
||||||
|
|
||||||
implementation group: 'com.google.guava', name: 'guava', version: '33.3.1-jre'
|
implementation group: 'com.google.guava', name: 'guava', version: '33.4.0-jre'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
// https://mvnrepository.com/artifact/com.google.code.gson/gson
|
||||||
implementation 'com.google.code.gson:gson:2.11.0'
|
implementation 'com.google.code.gson:gson:2.11.0'
|
||||||
|
@ -53,7 +58,7 @@ dependencies {
|
||||||
implementation("org.apache.commons:commons-compress:1.27.1") {
|
implementation("org.apache.commons:commons-compress:1.27.1") {
|
||||||
exclude group: 'com.github.luben', module: 'zstd-jni'
|
exclude group: 'com.github.luben', module: 'zstd-jni'
|
||||||
}
|
}
|
||||||
implementation 'com.github.luben:zstd-jni:1.5.6-8' // Even though this is part of the above dependency, the Apache commons rarely updates it, while the zstd team makes improvements very often.
|
implementation 'com.github.luben:zstd-jni:1.5.6-9' // Even though this is part of the above dependency, the Apache commons rarely updates it, while the zstd team makes improvements very often.
|
||||||
// Also, for compressing, we strangely need it to be explicitly declared independently, otherwise it does not work.
|
// Also, for compressing, we strangely need it to be explicitly declared independently, otherwise it does not work.
|
||||||
|
|
||||||
testImplementation 'org.springframework.security:spring-security-test'
|
testImplementation 'org.springframework.security:spring-security-test'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -86,8 +86,7 @@ done
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
|
@ -18,7 +18,7 @@ elif [[ $# -gt 1 ]]; then
|
||||||
echo -e "Wrong number of arguments given: ${#} (more than 1)\nPlease execute it like: script.sh <justRun: 0 | 1>"; exit 2
|
echo -e "Wrong number of arguments given: ${#} (more than 1)\nPlease execute it like: script.sh <justRun: 0 | 1>"; exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gradleVersion="8.11.1"
|
gradleVersion="8.12"
|
||||||
|
|
||||||
shouldBeCarefulWithMaxHeap=0 # This is NOT a cmd-arg.
|
shouldBeCarefulWithMaxHeap=0 # This is NOT a cmd-arg.
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import eu.openaire.publications_retriever.PublicationsRetriever;
|
||||||
import eu.openaire.urls_worker.components.ConnWithController;
|
import eu.openaire.urls_worker.components.ConnWithController;
|
||||||
import eu.openaire.urls_worker.controllers.FullTextsController;
|
import eu.openaire.urls_worker.controllers.FullTextsController;
|
||||||
import eu.openaire.urls_worker.util.UriBuilder;
|
import eu.openaire.urls_worker.util.UriBuilder;
|
||||||
|
import jakarta.annotation.PreDestroy;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -17,13 +18,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.web.cors.CorsConfiguration;
|
|
||||||
import org.springframework.web.cors.CorsConfigurationSource;
|
|
||||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,19 +100,6 @@ public class UrlsWorkerApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
public CorsConfigurationSource corsConfigurationSource() {
|
|
||||||
CorsConfiguration configuration = new CorsConfiguration();
|
|
||||||
configuration.setAllowedOrigins(Collections.singletonList("*"));
|
|
||||||
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"));
|
|
||||||
configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token"));
|
|
||||||
configuration.setExposedHeaders(Collections.singletonList("x-auth-token"));
|
|
||||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
||||||
source.registerCorsConfiguration("/**", configuration);
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CommandLineRunner setServerBaseUrl(Environment environment, ServletWebServerApplicationContext webServerAppCtxt)
|
public CommandLineRunner setServerBaseUrl(Environment environment, ServletWebServerApplicationContext webServerAppCtxt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class AssignmentsHandler {
|
||||||
private static final boolean askForTest = false; // Enable this only for testing.
|
private static final boolean askForTest = false; // Enable this only for testing.
|
||||||
private static String requestUrl;
|
private static String requestUrl;
|
||||||
|
|
||||||
public static final RestTemplate restTemplate = new RestTemplateBuilder().setConnectTimeout(Duration.ofMinutes(2)).setReadTimeout(Duration.ofHours(1)).build();
|
public static final RestTemplate restTemplate = new RestTemplateBuilder().connectTimeout(Duration.ofMinutes(2)).readTimeout(Duration.ofHours(1)).build();
|
||||||
|
|
||||||
public static boolean hadConnectionErrorOnRequest = false;
|
public static boolean hadConnectionErrorOnRequest = false;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.openaire.urls_worker.controllers;
|
||||||
import eu.openaire.urls_worker.components.AssignmentsHandler;
|
import eu.openaire.urls_worker.components.AssignmentsHandler;
|
||||||
import eu.openaire.urls_worker.components.plugins.PublicationsRetrieverPlugin;
|
import eu.openaire.urls_worker.components.plugins.PublicationsRetrieverPlugin;
|
||||||
import eu.openaire.urls_worker.util.UriBuilder;
|
import eu.openaire.urls_worker.util.UriBuilder;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -11,7 +12,6 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
|
@ -3,46 +3,51 @@ package eu.openaire.urls_worker.security;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
import org.springframework.security.config.Customizer;
|
||||||
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||||
import org.springframework.security.web.SecurityFilterChain;
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.web.cors.CorsConfiguration;
|
||||||
|
import org.springframework.web.cors.CorsConfigurationSource;
|
||||||
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebSecurity
|
@EnableWebSecurity
|
||||||
@EnableGlobalMethodSecurity (
|
@EnableMethodSecurity(securedEnabled = true, jsr250Enabled = true, prePostEnabled = true)
|
||||||
securedEnabled = false, // Just for now..
|
|
||||||
jsr250Enabled = true,
|
|
||||||
prePostEnabled = true
|
|
||||||
)
|
|
||||||
public class SecurityConfiguration {
|
public class SecurityConfiguration {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||||
http
|
http.cors(AbstractHttpConfigurer::disable)
|
||||||
.headers()
|
.csrf(AbstractHttpConfigurer::disable)
|
||||||
.frameOptions()
|
.sessionManagement(sessionManager -> sessionManager.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
|
||||||
.sameOrigin()
|
.exceptionHandling(Customizer.withDefaults())
|
||||||
.and()
|
.authorizeHttpRequests(authorizeHttpRequest -> authorizeHttpRequest.requestMatchers("/actuator/health", "/actuator/metrics", "/actuator/metrics/**", "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html", "/api/monitor/**", "/api/authentication/**")
|
||||||
.cors()
|
.permitAll()
|
||||||
.and()
|
.anyRequest()
|
||||||
.csrf()
|
.permitAll() // For now..
|
||||||
.disable()
|
);
|
||||||
.exceptionHandling()
|
|
||||||
.and()
|
|
||||||
.sessionManagement()
|
|
||||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
|
||||||
.and()
|
|
||||||
.authorizeRequests()
|
|
||||||
.antMatchers("/**").permitAll()
|
|
||||||
//.anyRequest().authenticated()
|
|
||||||
//.and()
|
|
||||||
//.requiresChannel()
|
|
||||||
//.anyRequest().requiresSecure()
|
|
||||||
;
|
|
||||||
return http.build();
|
return http.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public CorsConfigurationSource corsConfigurationSource() {
|
||||||
|
CorsConfiguration configuration = new CorsConfiguration();
|
||||||
|
configuration.setAllowedOrigins(Collections.singletonList("*"));
|
||||||
|
configuration.setAllowedMethods(Arrays.asList("GET", "POST"));
|
||||||
|
configuration.setAllowedHeaders(Arrays.asList("authorization", "content-type", "x-auth-token"));
|
||||||
|
configuration.setExposedHeaders(Collections.singletonList("x-auth-token"));
|
||||||
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||||
|
source.registerCorsConfiguration("/**", configuration);
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE configuration>
|
||||||
|
|
||||||
<configuration debug="false">
|
<configuration debug="false">
|
||||||
|
|
||||||
|
<!-- Silence internal status printing. Comment out to troubleshoot logging-errors. -->
|
||||||
|
<statusListener class="ch.qos.logback.core.status.NopStatusListener" />
|
||||||
|
|
||||||
|
<shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook"/>
|
||||||
|
|
||||||
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="RollingFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${LOG_PATH}/UrlsWorker.log</file>
|
<file>${LOG_PATH}/UrlsWorker.log</file>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue