Skip to content

Commit edab9aa

Browse files
authored
Merge pull request #1608 from tobixlea/tobixlea/headers
chore: remove springboot3 support and rearrange multi-value headers
2 parents ff25990 + 91826bf commit edab9aa

122 files changed

Lines changed: 21 additions & 7556 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/continuous-integration-workflow.yml

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,6 @@ jobs:
6565
# - name: Build with Spring 6.0.x
6666
# run: ./gha_build.sh spring false false -Dspring.version=6.0.16 -Dspring-security.version=6.1.10 -Ddependency-check.skip=true
6767

68-
build_springboot3:
69-
name: Build and test SpringBoot 3
70-
runs-on: ubuntu-latest
71-
steps:
72-
- uses: actions/checkout@v3
73-
- name: Set up JDK 17
74-
uses: actions/setup-java@v3
75-
with:
76-
distribution: 'corretto'
77-
java-version: 17
78-
- name: Build latest
79-
run: ./gha_build.sh springboot3 true true
80-
# Build with additional supported versions https://spring.io/projects/spring-boot#support
81-
- name: Build with Spring Boot 3.1.x
82-
run: ./gha_build.sh springboot3 false false -Dspringboot.version=3.1.12 -Dspring.version=6.0.21 -Dspringsecurity.version=6.1.9 -Ddependency-check.skip=true
83-
- name: Build with Spring Boot 3.2.x
84-
run: ./gha_build.sh springboot3 false false -Dspringboot.version=3.2.7 -Dspring.version=6.1.10 -Dspringsecurity.version=6.2.5 -Ddependency-check.skip=true
85-
- name: Build with Spring Boot 3.3.x
86-
run: ./gha_build.sh springboot3 false false -Dspringboot.version=3.3.6 -Dspring.version=6.1.15 -Dspringsecurity.version=6.3.5 -Ddependency-check.skip=true
8768

8869
build_springboot4:
8970
name: Build and test SpringBoot 4

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/internal/jaxrs/AwsProxySecurityContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public Principal getUserPrincipal() {
8787
case API_GATEWAY:
8888
return event.getRequestContext().getAuthorizer().getPrincipalId();
8989
case ALB:
90-
return event.getMultiValueHeaders().getFirst(ALB_IDENTITY_HEADER);
90+
return event.getMultiValueHeaders().getLast(ALB_IDENTITY_HEADER);
9191
}
9292
} else if (getAuthenticationScheme().equals(AUTH_SCHEME_AWS_IAM)) {
9393
// if we received credentials from Cognito Federated Identities then we return the identity id

aws-serverless-java-container-core/src/main/java/com/amazonaws/serverless/proxy/model/MultiValuedTreeMap.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ public Value getFirst(Key key) {
6161
return values.get(0);
6262
}
6363

64+
public Value getLast(Key key) {
65+
List<Value> values = get(key);
66+
if (values == null || values.isEmpty()) {
67+
return null;
68+
}
69+
return values.get(values.size() - 1);
70+
}
71+
6472
@Override
6573
public void putSingle(Key key, Value value) {
6674
List<Value> values = findKey(key);

aws-serverless-java-container-core/src/test/java/com/amazonaws/serverless/proxy/internal/jaxrs/AwsProxySecurityContextTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ public class AwsProxySecurityContextTest {
2525
.header(ALB_ACESS_TOKEN_HEADER, "xxxxx")
2626
.header(ALB_IDENTITY_HEADER, COGNITO_IDENTITY_ID)
2727
.build();
28+
private static final AwsProxyRequest ALB_REQUEST_MULTIPLE_HEADERS = new AwsProxyRequestBuilder("/hello", "GET")
29+
.alb()
30+
.header(ALB_ACESS_TOKEN_HEADER, "xxxxx")
31+
.header(ALB_IDENTITY_HEADER, "test-identity")
32+
.header(ALB_IDENTITY_HEADER, COGNITO_IDENTITY_ID)
33+
.build();
2834

2935
@Test
3036
void localVars_constructor_nullValues() {
@@ -71,6 +77,12 @@ void alb_cognitoAuth_expectCustomSchemeAndCorrectPrincipal() {
7177
assertEquals(COGNITO_IDENTITY_ID, context.getUserPrincipal().getName());
7278
}
7379

80+
@Test
81+
void alb_multipleIdentityHeaders_usesLastValue() {
82+
AwsProxySecurityContext context = new AwsProxySecurityContext(null, ALB_REQUEST_MULTIPLE_HEADERS);
83+
assertEquals(COGNITO_IDENTITY_ID, context.getUserPrincipal().getName());
84+
}
85+
7486
@Test
7587
void userPool_getClaims_retrieveCustomClaim() {
7688
AwsProxySecurityContext context = new AwsProxySecurityContext(null, REQUEST_COGNITO_USER_POOL);

0 commit comments

Comments
 (0)