Skip to content
Closed
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
12 changes: 0 additions & 12 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,6 @@ services:
- 8090:8090
- 5005:5005

header:
image: georchestra/header:latest
volumes:
- datadir:/etc/georchestra
environment:
- JAVA_OPTIONS=-Dorg.eclipse.jetty.annotations.AnnotationParser.LEVEL=OFF
- XMS=256M
- XMX=512M
restart: always
ports:
- 10003:8080

geoserver:
image: georchestra/geoserver:latest
depends_on:
Expand Down
25 changes: 17 additions & 8 deletions gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<!-- override provided version 2.26.3 -->
<version>2.35.1</version>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-jakarta</artifactId>
<!-- Jakarta EE compatible version for Spring Boot 3 -->
<version>3.4.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand All @@ -41,6 +41,10 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
Expand Down Expand Up @@ -101,8 +105,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8</artifactId>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -144,12 +148,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<!-- override provided version 2.22.2 -->
<version>3.0.0-M6</version>
<version>3.1.2</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.11</version>
<version>0.8.12</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down Expand Up @@ -326,6 +330,11 @@
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Objects;
import java.util.Optional;

import jakarta.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.georchestra.ds.DataServiceException;
import org.georchestra.ds.DuplicatedCommonNameException;
Expand Down Expand Up @@ -250,7 +251,7 @@ private void ensureRoleExists(String role) throws DataServiceException {
roleDao.findByCommonName(role);
} catch (NameNotFoundException notFound) {
try {
roleDao.insert(RoleFactory.create(role, null, null));
roleDao.insert(RoleFactory.create(role, null, false));
} catch (DuplicatedCommonNameException e) {
throw new IllegalStateException(e);
}
Expand Down Expand Up @@ -281,8 +282,8 @@ private Account mapToAccountBrief(@NonNull GeorchestraUser preAuth) {
String phone = "";
String title = "";
String description = "";
final @javax.annotation.Nullable String oAuth2Provider = preAuth.getOAuth2Provider();
final @javax.annotation.Nullable String oAuth2Uid = preAuth.getOAuth2Uid();
final @Nullable String oAuth2Provider = preAuth.getOAuth2Provider();
final @Nullable String oAuth2Uid = preAuth.getOAuth2Uid();

Account newAccount = AccountFactory.createBrief(username, password, firstName, lastName, email, phone, title,
description, oAuth2Provider, oAuth2Uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,6 @@ private String getMaxMem() {
value = value / 1024d;
unit = "GB";
}
return String.format("%.2f %s", value, unit);
return "%.2f %s".formatted(value, unit);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
*/
package org.georchestra.gateway.app;

import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;

import org.apache.commons.lang3.tuple.Pair;
import org.georchestra.gateway.security.GeorchestraGatewaySecurityConfigProperties;
Expand Down Expand Up @@ -144,7 +144,7 @@ public String loginPage(@RequestParam Map<String, String> allRequestParams, Mode
if (oauth2ClientConfig != null) {
oauth2ClientConfig.getRegistration().forEach((key, value) -> {
String clientName = Optional.ofNullable(value.getClientName()).orElse(key);
String providerPath = Paths.get("login/img/", key + ".png").toString();
String providerPath = Path.of("login/img/", key + ".png").toString();
String logo = new ClassPathResource("static/" + providerPath).exists() ? providerPath
: "login/img/default.png";
oauth2LoginLinks.put("/oauth2/authorization/" + key, Pair.of(clientName, logo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Map;
import java.util.Optional;

import lombok.RequiredArgsConstructor;
import org.georchestra.gateway.security.GeorchestraUserMapper;
import org.georchestra.gateway.security.exceptions.DuplicatedEmailFoundException;
import org.georchestra.security.model.GeorchestraUser;
Expand All @@ -42,6 +43,7 @@
* </p>
*/
@RestController
@RequiredArgsConstructor
public class WhoamiController {

/**
Expand All @@ -50,17 +52,6 @@ public class WhoamiController {
*/
private final GeorchestraUserMapper userMapper;

/**
* Constructs a {@code WhoamiController} with a user mapper for authentication
* resolution.
*
* @param userMapper the {@link GeorchestraUserMapper} used to resolve
* authentication details
*/
public WhoamiController(GeorchestraUserMapper userMapper) {
this.userMapper = userMapper;
}

/**
* Returns details about the currently authenticated user.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;

import org.georchestra.gateway.accounts.admin.ldap.GeorchestraLdapAccountManagementConfiguration;
import org.georchestra.gateway.security.ldap.extended.ExtendedLdapAuthenticationConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import org.georchestra.gateway.handler.predicate.QueryParamRoutePredicateFactory;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.georchestra.gateway.autoconfigure.security;

import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;

import org.georchestra.gateway.security.ldap.LdapAuthenticationConfiguration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.georchestra.gateway.autoconfigure.security;

import javax.annotation.PostConstruct;
import jakarta.annotation.PostConstruct;

import org.georchestra.gateway.security.oauth2.OAuth2Configuration;
import org.springframework.boot.autoconfigure.AutoConfiguration;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory;
import org.springframework.core.Ordered;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
Expand All @@ -37,6 +37,8 @@
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Mono;

import static org.springframework.http.HttpMethod.HEAD;

/**
* Gateway filter that enables custom error pages when a proxied application
* responds with an error status, applicable only for idempotent HTTP methods
Expand Down Expand Up @@ -163,10 +165,8 @@ boolean canFilter(ServerHttpRequest request) {
* @return {@code true} if the method is idempotent, {@code false} otherwise
*/
boolean methodIsIdempotent(HttpMethod method) {
return switch (method) {
case GET, HEAD, OPTIONS, TRACE -> true;
default -> false;
};
return method == HttpMethod.GET || method == HttpMethod.HEAD || method == HttpMethod.OPTIONS
|| method == HttpMethod.TRACE;
}

/**
Expand Down Expand Up @@ -203,7 +203,7 @@ public void beforeCommit(Supplier<? extends Mono<Void>> action) {
* or 5xx range, allowing the gateway to apply custom error handling.
*/
private void checkStatusCode() {
HttpStatus statusCode = getStatusCode();
HttpStatusCode statusCode = getStatusCode();
log.debug("native status code: {}", statusCode);
if (statusCode.is4xxClientError() || statusCode.is5xxServerError()) {
log.debug("Conveying {} response status", statusCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.georchestra.gateway.filter.headers;

import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;

import org.georchestra.gateway.filter.global.ResolveTargetGlobalFilter;
import org.springframework.cloud.gateway.filter.GatewayFilter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.List;
import java.util.function.Predicate;

import javax.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotEmpty;

import org.springframework.cloud.gateway.handler.predicate.AbstractRoutePredicateFactory;
import org.springframework.cloud.gateway.handler.predicate.GatewayPredicate;
Expand Down Expand Up @@ -93,7 +93,7 @@ public boolean test(ServerWebExchange exchange) {

@Override
public String toString() {
return String.format("Query: param=%s", config.getParam());
return "Query: param=%s".formatted(config.getParam());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@

log.info("Initializing security filter chain...");

http.csrf().disable();
http.headers().disable();
http.exceptionHandling().accessDeniedHandler(new CustomAccessDeniedHandler());
http.csrf(csrf -> csrf.disable());
Comment thread Dismissed
http.headers(headers -> headers.disable());
http.exceptionHandling(handling -> handling.accessDeniedHandler(new CustomAccessDeniedHandler()));

http.formLogin()
http.formLogin(login -> login
.authenticationFailureHandler(new ExtendedRedirectServerAuthenticationFailureHandler("login?error"))
.loginPage("/login");
.loginPage("/login"));

sortedCustomizers(customizers).forEach(customizer -> {
log.debug("Applying security customizer {}", customizer.getName());
Expand All @@ -130,11 +130,11 @@
RedirectServerLogoutSuccessHandler defaultRedirect = new RedirectServerLogoutSuccessHandler();
defaultRedirect.setLogoutSuccessUrl(URI.create(georchestraLogoutUrl));

LogoutSpec logoutSpec = http.formLogin().loginPage("/login").and().logout()
ServerHttpSecurity logoutSpec = http.formLogin(login -> login.loginPage("/login")).logout(logout -> logout
.requiresLogout(ServerWebExchangeMatchers.pathMatchers(HttpMethod.GET, "/logout"))
.logoutSuccessHandler(oidcLogoutSuccessHandler != null ? oidcLogoutSuccessHandler : defaultRedirect);
.logoutSuccessHandler(oidcLogoutSuccessHandler != null ? oidcLogoutSuccessHandler : defaultRedirect));

return logoutSpec.and().build();
return logoutSpec.build();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Map.Entry;
import java.util.stream.Stream;

import javax.validation.Valid;
import jakarta.validation.Valid;

import org.georchestra.gateway.security.ldap.LdapConfigBuilder;
import org.georchestra.gateway.security.ldap.LdapConfigPropertiesValidations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public boolean matches(String role) {

@Override
public String toString() {
return String.format("%s -> %s", pattern.pattern(), extraRoles);
return "%s -> %s".formatted(pattern.pattern(), extraRoles);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.georchestra.gateway.security.accessrules;

import static org.springframework.security.config.Customizer.withDefaults;

import java.util.List;
import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.georchestra.gateway.security.ldap;

import static org.springframework.security.config.Customizer.withDefaults;

import java.util.List;
import java.util.stream.Stream;

Expand Down Expand Up @@ -55,8 +57,8 @@
* </p>
* <p>
* As a result, the {@link ServerHttpSecurity} will have HTTP Basic
* authentication enabled, as well as {@link ServerHttpSecurity#formLogin() form
* login}.
* authentication enabled, as well as
* {@link ServerHttpSecurity#formLogin(withDefaults()) form login}.
* </p>
* <p>
* Upon successful authentication, an {@link Authentication} instance will be
Expand Down Expand Up @@ -96,7 +98,7 @@ public static final class LDAPAuthenticationCustomizer implements ServerHttpSecu
*/
public @Override void customize(ServerHttpSecurity http) {
log.info("Enabling HTTP Basic authentication support for LDAP");
http.httpBasic().and().formLogin();
http.httpBasic(withDefaults()).formLogin(withDefaults());
}
}

Expand Down
Loading