Skip to content

Commit 53200d6

Browse files
committed
Merge branch 'main' into devJsonExtraction
2 parents 85e2537 + cd35689 commit 53200d6

File tree

8 files changed

+81
-44
lines changed

8 files changed

+81
-44
lines changed

.github/workflows/create-release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
should_run_next_job: ${{ steps.check-tag.outputs.should_continue }}
2222
steps:
2323
- name: Set up JDK 21
24-
uses: actions/setup-java@v4
24+
uses: actions/setup-java@v5
2525
with:
2626
distribution: 'temurin'
2727
java-version: '21'
@@ -64,7 +64,7 @@ jobs:
6464
runs-on: ubuntu-latest
6565
steps:
6666
- name: Set up JDK 21
67-
uses: actions/setup-java@v4
67+
uses: actions/setup-java@v5
6868
with:
6969
distribution: 'temurin'
7070
java-version: '21'

.github/workflows/docker.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
ref: ${{ steps.extract_branch.outputs.branch }}
2222

2323
- name: Set up JDK 21
24-
uses: actions/setup-java@v4
24+
uses: actions/setup-java@v5
2525
with:
2626
distribution: "temurin"
2727
java-version: "21"

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v5
2424

2525
- name: Set up JDK 21
26-
uses: actions/setup-java@v4
26+
uses: actions/setup-java@v5
2727
with:
2828
java-version: '21'
2929
distribution: 'temurin'

.github/workflows/scheduled-version-update.yaml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ permissions:
66

77
on:
88
schedule:
9-
- cron: 45 7 * * 4
9+
# 08:30 Europe/Paris pendant l'heure d'été (CEST = UTC+2)
10+
# mois 3-10 (mars à octobre inclus)
11+
- cron: '30 6 * 3-10 4'
12+
# 08:30 Europe/Paris pendant l'heure d'hiver (CET = UTC+1)
13+
# mois 11,12,1,2 (novembre, décembre, janvier, février)
14+
- cron: '30 7 * 11,12,1,2 4'
1015
workflow_dispatch:
1116

1217
jobs:
@@ -24,7 +29,13 @@ jobs:
2429
id: current_sha
2530
run: |
2631
cd genesis
27-
CURRENT_SHA=$(git log -n 1 --pretty=format:"%H")
32+
CURRENT_SHA=$(
33+
git log --pretty=format:"%H" \
34+
--invert-grep --grep="^ci:" \
35+
--invert-grep --grep="^Merge branch 'main'" \
36+
--invert-grep --grep="^Revert " \
37+
-n 1
38+
)
2839
echo "last commit SHA : $CURRENT_SHA"
2940
echo "current_sha=$CURRENT_SHA" >> $GITHUB_OUTPUT
3041
@@ -44,7 +55,7 @@ jobs:
4455
run: |
4556
if [ "${{ steps.current_sha.outputs.current_sha }}" = "${{ steps.last_tag.outputs.tag_sha }}" ]; then
4657
echo "No new commit since version. Exiting."
47-
exit 0
58+
exit 1
4859
fi
4960
5061
- name: Get version from changelog
@@ -122,19 +133,21 @@ jobs:
122133
' "$FILE"; then
123134
echo "Adding BPM ${BPM_VERSION} to existing updated section"
124135
awk -v ver="^## ${NEW_VERSION_NO_V}" -v newline="$NEW_LINE" '
125-
$0 ~ ver {print; in_ver=1; next}
126-
in_ver && /^## / {in_ver=0}
127-
in_ver && /^### Updated/ {print; print newline; next}
128-
{print}
136+
$0 ~ ver {print; in_ver=1; next}
137+
in_ver && /^## / {in_ver=0}
138+
in_ver && !done && /^### Updated/ {print; print newline; done=1; next}
139+
{print}
129140
' "$FILE" > tmp && mv tmp "$FILE"
130141
else
131142
### New changed section
132143
echo "Adding BPM ${BPM_VERSION} to a new updated section"
133144
awk -v ver="^## ${NEW_VERSION_NO_V}" -v newline="$NEW_LINE" '
134-
$0 ~ ver {print; in_ver=1; next}
135-
in_ver && /^## / {print "### Updated"; print newline; in_ver=0}
136-
{print}
137-
END { if(in_ver) {print "### Updated"; print newline} }
145+
$0 ~ ver {print; in_ver=1; next}
146+
in_ver && /^## / && !done {
147+
print "### Updated"; print newline; in_ver=0; done=1
148+
}
149+
{print}
150+
END { if(in_ver && !done) {print "### Updated"; print newline} }
138151
' "$FILE" > tmp && mv tmp "$FILE"
139152
fi
140153
fi

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
11
# Changelog
2+
## 1.8.4 [2025-09-11]
3+
### Updated
4+
- Sonar 5.2.0.4988
5+
- Springdoc openapi webmvc 2.8.13
6+
- Cucumber 7.28.2
7+
8+
9+
## 1.8.3 [2025-08-28]
10+
### Updated
11+
- Springboot 3.5.5
12+
- Springdoc openapi webmvc 2.8.11
13+
14+
### Added
15+
- CI pipeline
16+
217
## 1.8.2 [2025-08-19]
318
### Updated
419
- BPM 1.0.13

pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>fr.insee.genesis</groupId>
66
<artifactId>genesis-api</artifactId>
7-
<version>1.8.2</version>
7+
<version>1.8.4</version>
88
<packaging>jar</packaging>
99
<name>genesis-api</name>
1010

1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>3.5.4</version>
14+
<version>3.5.5</version>
1515
</parent>
1616

1717
<properties>
1818
<java.version>21</java.version>
19-
<springdoc.version>2.8.9</springdoc.version>
19+
<springdoc.version>2.8.13</springdoc.version>
2020
<mapstruct.version>1.6.3</mapstruct.version>
21-
<cucumber.version>7.27.2</cucumber.version>
21+
<cucumber.version>7.28.2</cucumber.version>
2222
<junit-jupiter.version>5.13.4</junit-jupiter.version>
2323

2424
<!-- Proprietes sonar -->
@@ -34,7 +34,7 @@
3434
<pitest.version>1.20.2</pitest.version>
3535
<pitest.junit.version>1.2.3</pitest.junit.version>
3636
<jackson.version>2.19.0</jackson.version>
37-
<bpm.version>1.0.13</bpm.version>
37+
<bpm.version>1.0.15</bpm.version>
3838
</properties>
3939
<dependencies>
4040
<dependency>
@@ -171,7 +171,7 @@
171171
<plugin>
172172
<groupId>org.sonarsource.scanner.maven</groupId>
173173
<artifactId>sonar-maven-plugin</artifactId>
174-
<version>5.1.0.4751</version>
174+
<version>5.2.0.4988</version>
175175
</plugin>
176176
<plugin>
177177
<groupId>org.jacoco</groupId>

src/main/java/fr/insee/genesis/configuration/auth/security/OIDCSecurityConfig.java

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.security.oauth2.server.resource.authentication.JwtIssuerAuthenticationManagerResolver;
2727
import org.springframework.security.web.SecurityFilterChain;
2828

29+
import java.util.ArrayList;
2930
import java.util.Collection;
3031
import java.util.Collections;
3132
import java.util.HashMap;
@@ -112,39 +113,47 @@ Converter<Jwt, Collection<GrantedAuthority>> jwtGrantedAuthoritiesConverter() {
112113
@Override
113114
@SuppressWarnings({"unchecked"})
114115
public Collection<GrantedAuthority> convert(Jwt source) {
115-
116-
String[] claimPath = inseeSecurityTokenProperties.getOidcClaimRole().split("\\.");
117-
Map<String, Object> claims = source.getClaims();
118116
try {
117+
List<String> allTokenClaims = new ArrayList<>();
118+
119+
// 🔹 1. Retrieve roles from realm_access.roles
120+
String[] claimPath = inseeSecurityTokenProperties.getOidcClaimRole().split("\\.");
121+
Map<String, Object> claims = source.getClaims();
119122
for (int i = 0; i < claimPath.length - 1; i++) {
120123
claims = (Map<String, Object>) claims.get(claimPath[i]);
121124
}
122125
if (claims != null) {
123126
List<String> tokenClaims = (List<String>) claims.getOrDefault(claimPath[claimPath.length - 1], List.of());
124-
// Collect distinct values from mapping associated with input keys
125-
List<String> claimedRoles = tokenClaims.stream()
126-
.filter(roleConfiguration.getRolesByClaim()::containsKey) // Ensure the key exists in the mapping
127-
.flatMap(key -> roleConfiguration.getRolesByClaim().get(key).stream()) // Get the list of values associated with the key
128-
.distinct() // Remove duplicates
129-
.toList();
130-
131-
return Collections.unmodifiableCollection(claimedRoles.stream().map(s -> new GrantedAuthority() {
132-
@Override
133-
public String getAuthority() {
134-
return ROLE_PREFIX + s;
135-
}
136-
137-
@Override
138-
public String toString() {
139-
return getAuthority();
140-
}
141-
}).toList());
127+
allTokenClaims.addAll(tokenClaims);
128+
}
129+
130+
// 🔹 2. Retrieve roles from inseegroupedefaut
131+
Object inseeGroups = source.getClaims().get("inseegroupedefaut");
132+
if (inseeGroups instanceof List<?> groups) {
133+
groups.stream()
134+
.filter(String.class::isInstance)
135+
.map(String.class::cast)
136+
.forEach(allTokenClaims::add);
142137
}
138+
139+
// 🔹 3. Mapping with Spring roles
140+
List<String> claimedRoles = allTokenClaims.stream()
141+
.filter(roleConfiguration.getRolesByClaim()::containsKey)
142+
.flatMap(key -> roleConfiguration.getRolesByClaim().get(key).stream())
143+
.distinct()
144+
.toList();
145+
146+
// 🔹 4. Transforms in GrantedAuthority
147+
return Collections.unmodifiableCollection(
148+
claimedRoles.stream()
149+
.map(s -> (GrantedAuthority) () -> ROLE_PREFIX + s)
150+
.toList()
151+
);
152+
143153
} catch (ClassCastException e) {
144154
// role path not correctly found, assume that no role for this user
145155
return List.of();
146156
}
147-
return List.of();
148157
}
149158
};
150159
}

src/main/java/fr/insee/genesis/controller/rest/DataProcessingContextController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class DataProcessingContextController {
4646

4747
@Operation(summary = "Create or update a data processing context")
4848
@PutMapping(path = "/review")
49-
@PreAuthorize("hasRole('USER_BACK_OFFICE')")
49+
@PreAuthorize("hasAnyRole('USER_BACK_OFFICE','SCHEDULER')")
5050
public ResponseEntity<Object> saveContext(
5151
@Parameter(description = "Identifier of the partition", required = true) @RequestParam("partitionId") String partitionId,
5252
@Parameter(description = "Allow reviewing") @RequestParam(value = "withReview", defaultValue = "false") Boolean withReview

0 commit comments

Comments
 (0)