Skip to content

Commit

Permalink
Relocate sources and build georchestra dependencies
Browse files Browse the repository at this point in the history
- fall back to Java 11. Georchestra modules won't build
with Java 17. Revisit and possibly fix upstream.
  • Loading branch information
groldan committed Apr 14, 2022
1 parent 9c56c1d commit e8b3f28
Show file tree
Hide file tree
Showing 61 changed files with 265 additions and 224 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: 'true'

- name: "Setting up Java"
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '11'
cache: 'maven'

- name: Initialize CodeQL
Expand All @@ -52,3 +54,4 @@ jobs:

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2

13 changes: 9 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,29 @@ jobs:
steps:
- name: "Checking out"
uses: actions/checkout@v3
with:
submodules: 'true'

- name: "Setting up Java"
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
java-version: '11'
cache: 'maven'

- name: mvn clean test verify
run: ./mvnw clean test verify -ntp -T1C
- name: Build georchestra dependencies
run: ./mvnw -f georchestra/ clean install -pl :georchestra-ldap-account-management -am -DskipTests -P-all -ntp

- name: Build gateway
run: ./mvnw verify -pl :georchestra-gateway -ntp -T1C

- name: Calculating docker image tag
id: version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)

- name: "Building a docker image"
if: github.repository == 'georchestra/georchestra-gateway'
run: ./mvnw -DimageTag=${{ steps.version.outputs.VERSION }} spring-boot:build-image -ntp
run: ./mvnw -f gateway/ -DimageTag=${{ steps.version.outputs.VERSION }} spring-boot:build-image -ntp -DskipTests

- name: "Logging in to docker.io"
if: github.repository == 'georchestra/georchestra-gateway'
Expand Down
6 changes: 6 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED

221 changes: 221 additions & 0 deletions gateway/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.georchestra</groupId>
<artifactId>georchestra-gateway-parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>georchestra-gateway</artifactId>
<name>gateway</name>
<description>geOrchestra application gateway</description>
<properties>
<java.version>11</java.version>
<imageTag>${project.version}</imageTag>
<spring-boot.build-image.imageName>georchestra/gateway:${imageTag}</spring-boot.build-image.imageName>
</properties>
<dependencies>
<dependency>
<groupId>org.georchestra</groupId>
<artifactId>georchestra-ldap-account-management</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<!-- Annotation processor that generates metadata about classes annotated with @ConfigurationProperties. -->
<!-- This metadata is used by IDEs to provide auto-completion and documentation for the properties when editing application.properties
and application.yaml -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<!-- Generates META-INF/spring-autoconfigure-metadata.properties for inclusion in the project's jar. -->
<!-- This file helps with startup time, but is not necessary for your app to function correctly. -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.springframework.security</groupId> -->
<!-- <artifactId>spring-security-test</artifactId> -->
<!-- <scope>test</scope> -->
<!-- </dependency> -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>${fmt.action}</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<skip>${fmt.skip}</skip>
<configFile>${maven.multiModuleProjectDirectory}/.mvn/formatter.xml</configFile>
<compilerSource>${java.version}</compilerSource>
<compilerCompliance>${java.version}</compilerCompliance>
<compilerTargetPlatform>${java.version}</compilerTargetPlatform>
<!-- Use Unix and Mac style line endings -->
<lineEnding>LF</lineEnding>
<encoding>UTF-8</encoding>
<skipJsFormatting>true</skipJsFormatting>
<skipCssFormatting>true</skipCssFormatting>
<skipHtmlFormatting>true</skipHtmlFormatting>
<skipJsonFormatting>true</skipJsonFormatting>
<skipXmlFormatting>true</skipXmlFormatting>
<skipJavaFormatting>false</skipJavaFormatting>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-maven-and-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[11,)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>[3.6.3,)</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.github.ekryd.sortpom</groupId>
<artifactId>sortpom-maven-plugin</artifactId>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>${pom.fmt.action}</goal>
</goals>
</execution>
</executions>
<configuration>
<skip>${pom.fmt.skip}</skip>
<pomFile>pom.xml</pomFile>
<keepBlankLines>true</keepBlankLines>
<spaceBeforeCloseEmptyElement>false</spaceBeforeCloseEmptyElement>
<createBackupFile>false</createBackupFile>
<verifyFail>stop</verifyFail>
<verifyFailOn>strict</verifyFailOn>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
<configuration>
<updatePomFile>true</updatePomFile>
<!--flattenMode>resolveCiFriendliesOnly</flattenMode -->
<flattenMode>oss</flattenMode>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>docker</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-image</id>
<goals>
<goal>build-image</goal>
</goals>
</execution>
</executions>
<configuration>
<image>
<pullPolicy>IF_NOT_PRESENT</pullPolicy>
</image>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.georchestra.gateway.filter.headers.HeaderContributor;
import org.georchestra.gateway.model.GeorchestraTargetConfig;
Expand Down Expand Up @@ -55,7 +56,7 @@ public class GeorchestraUserHeadersContributor extends HeaderContributor {
add(headers, "sec-tel", mappings.getTel(), user.map(GeorchestraUser::getTelephoneNumber));

List<String> roles = user.map(GeorchestraUser::getRoles).orElse(List.of()).stream()
.map(r -> r.startsWith("ROLE_") ? r : "ROLE_" + r).toList();
.map(r -> r.startsWith("ROLE_") ? r : "ROLE_" + r).collect(Collectors.toList());

add(headers, "sec-roles", mappings.getRoles(), roles);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.georchestra.gateway.model.GeorchestraUsers;
import org.georchestra.security.model.GeorchestraUser;
Expand Down Expand Up @@ -49,7 +50,7 @@ Optional<GeorchestraUser> map(UsernamePasswordAuthenticationToken token) {
GeorchestraUser user = new GeorchestraUser();

Collection<GrantedAuthority> authorities = token.getAuthorities();
List<String> roles = authorities.stream().map(GrantedAuthority::getAuthority).toList();
List<String> roles = authorities.stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
String name = token.getName();

Object principal = token.getPrincipal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http,
});

log.info("Security filter chain initialized");
// http.authorizeExchange()//
// .pathMatchers("/", "/header/**").permitAll()//
// .pathMatchers("/ws/**").permitAll()//
// .pathMatchers("/**").authenticated();

return http.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.georchestra.gateway.model.GeorchestraUsers;
import org.georchestra.gateway.security.GeorchestraUserMapperExtension;
Expand Down Expand Up @@ -79,7 +80,7 @@ protected List<String> resolveRoles(Collection<? extends GrantedAuthority> autho
return false;
}
return true;
}).toList();
}).collect(Collectors.toList());
return roles;
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion georchestra
Submodule georchestra updated 1 files
+1 −1 pom.xml
Loading

0 comments on commit e8b3f28

Please sign in to comment.