Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/jdk21 #2

Merged
merged 5 commits into from
Dec 3, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '11'
java-version: '21'
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Codecov
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- name: Check out code
uses: actions/checkout@v4

- name: Set up JAVA 11
- name: Set up JAVA 21
uses: actions/setup-java@v4
with:
java-version: 11
java-version: 21
distribution: "temurin"

- name: Determine the version
Expand All @@ -41,21 +41,21 @@ jobs:
exit 1
if: github.event_name != 'workflow_dispatch' && steps.versioncheck.outputs.version != github.ref_name

- name: Set up JDK 11 for snapshots
- name: Set up JDK 21 for snapshots
uses: actions/setup-java@v4
with:
java-version: "11"
java-version: "21"
distribution: "temurin"
cache: "maven"
server-id: openconext-snapshots
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
if: ( endsWith(steps.versioncheck.outputs.version, '-SNAPSHOT'))

- name: Set up JDK 11 for releases
- name: Set up JDK 21 for releases
uses: actions/setup-java@v4
with:
java-version: "11"
java-version: "21"
distribution: "temurin"
cache: "maven"
server-id: openconext-releases
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM eclipse-temurin:11-jdk-alpine
FROM eclipse-temurin:21-jdk-alpine
RUN apk --update upgrade && apk add openssl openssl-dev ca-certificates libgcc && update-ca-certificates
COPY target/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
57 changes: 44 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.0</version>
<version>2.7.18</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>org.surfnet</groupId>
<artifactId>student-mobility-home-institution-mock</artifactId>
<version>0.2.14-SNAPSHOT</version>
<version>0.3.0-SNAPSHOT</version>
<name>home-institution-mock</name>
<description>home-institution-mock</description>
<properties>
<java.version>11</java.version>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<java.version>21</java.version>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
</properties>
<dependencies>
<dependency>
Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
<version>2.4.0</version>
<version>2.7.18</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -64,7 +64,7 @@
<dependency>
<groupId>com.github.spullara.mustache.java</groupId>
<artifactId>compiler</artifactId>
<version>0.9.6</version>
<version>0.9.14</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -75,19 +75,19 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.2.0</version>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>4.2.0</version>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>4.2.0</version>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.tomakehurst/wiremock -->
Expand Down Expand Up @@ -122,18 +122,49 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<release>21</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<id>enforce-versions</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.8.4</version>
</requireMavenVersion>
<requireJavaVersion>
<version>21</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.2</version>
<version>4.9.10</version>
<configuration>
<useNativeGit>true</useNativeGit>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<version>0.8.12</version>
<configuration>
<excludes>
<exclude>**/*MockMailBox.*</exclude>
Expand All @@ -159,7 +190,7 @@
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>3.3.4</version>
<version>3.5.3</version>
</extension>
</extensions>
</build>
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/home/SecurityConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,16 @@ public static class OAuth2SecurityConfigurationAdapter extends WebSecurityConfig
protected void configure(HttpSecurity http) throws Exception {
DefaultBearerTokenResolver tokenResolver = new DefaultBearerTokenResolver();
tokenResolver.setAllowFormEncodedBodyParameter(true);
http.requestMatchers().antMatchers("/persons/**", "/associations/**", "/oauth2/offerings/**")
http.requestMatchers()
.antMatchers("/persons/**", "/associations/**", "/oauth2/offerings/**")
.and()
.authorizeRequests(authz -> authz
.antMatchers(HttpMethod.GET)
.hasAuthority("SCOPE_openid")
.anyRequest().authenticated())
.sessionManagement(sessionManagement ->
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
.csrf().disable()
.oauth2ResourceServer().bearerTokenResolver(tokenResolver).opaqueToken();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ logging:
root: warn
home: debug
org.springframework: info
org.springframework.security: trace

delay:
enabled: true
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/home/api/PersonEndpointTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package home.api;

import home.AbstractIntegrationTest;
import io.restassured.config.EncoderConfig;
import io.restassured.config.RestAssuredConfig;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;

import java.io.IOException;

Expand Down Expand Up @@ -31,8 +34,13 @@ void persons() throws Exception {
void personsPost() throws Exception {
String accessToken = opaqueAccessToken(true);
given()
.config(RestAssuredConfig.config()
.encoderConfig(EncoderConfig.encoderConfig()
///Bugfix for the DefaultBearerTokenResolver being strict in content type checking
.appendDefaultContentCharsetToContentTypeIfUndefined(false)))
.when()
.formParam("access_token", accessToken)
.contentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE)
.post("/persons/me")
.then()
.statusCode(SC_OK)
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<appender-ref ref="STDOUT"/>
</root>
<logger name="org.springframework" level="WARN"/>
<logger name="org.springframework.security" level="TRACE"/>
<logger name="home" level="DEBUG"/>
</configuration>
Loading