-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preauth - being able to receive base64-encoded headers
As Netty will always consider received headers as US-ASCII encoded, this can lead to issues when the values contain accented characters. With this new feature, it is possible to consider the values as base64-encoded, which will be decoded before use. Tests: IT added.
- Loading branch information
Showing
8 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...rg/georchestra/gateway/accounts/admin/PreauthHttpHeadersBase64EncodedCreateAccountIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package org.georchestra.gateway.accounts.admin; | ||
|
||
import org.georchestra.ds.orgs.OrgsDao; | ||
import org.georchestra.ds.users.Account; | ||
import org.georchestra.ds.users.AccountDao; | ||
import org.georchestra.gateway.app.GeorchestraGatewayApplication; | ||
import org.georchestra.gateway.security.preauth.HeaderPreauthConfigProperties; | ||
import org.georchestra.testcontainers.ldap.GeorchestraLdapContainer; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
@SpringBootTest(classes = GeorchestraGatewayApplication.class) | ||
@AutoConfigureWebTestClient(timeout = "PT20S") | ||
@ActiveProfiles({ "createaccount", "preauthbase64encoded" }) | ||
public class PreauthHttpHeadersBase64EncodedCreateAccountIT { | ||
|
||
private @Autowired WebTestClient testClient; | ||
|
||
private @Autowired ApplicationContext context; | ||
|
||
private @Autowired AccountDao accountDao; | ||
|
||
private @Autowired OrgsDao orgsDao; | ||
|
||
public static GeorchestraLdapContainer ldap = new GeorchestraLdapContainer(); | ||
|
||
public static @BeforeAll void startUpContainers() { | ||
ldap.start(); | ||
} | ||
|
||
public static @AfterAll void shutDownContainers() { | ||
ldap.stop(); | ||
} | ||
|
||
public @Test void testPreauthenticatedHeaders_AccentedChars() throws Exception { | ||
testClient.get().uri("/whoami")// | ||
.header("sec-georchestra-preauthenticated", "true")// | ||
.header("preauth-username", "{base64}ZnZhbmRlcmJsYWg=")// | ||
.header("preauth-email", "{base64}ZnZhbmRlcmJsYWhAZ2VvcmNoZXN0cmEub3Jn")// | ||
.header("preauth-firstname", "{base64}RnJhbsOnb2lz")// | ||
.header("preauth-lastname", "{base64}VmFuIERlciBBY2NlbnTDqWQgQ2jDoHJhY3TDqHJz")// | ||
.header("preauth-org", "{base64}R0VPUkNIRVNUUkE=")// | ||
.exchange()// | ||
.expectStatus()// | ||
.is2xxSuccessful()// | ||
.expectBody()// | ||
.jsonPath("$.GeorchestraUser").isNotEmpty(); | ||
|
||
// Make sure the account has been created and the strings have been correctly | ||
// evaluated at creation | ||
Account toTest = accountDao.findByUID("fvanderblah"); | ||
|
||
assertTrue( | ||
toTest.getSurname().equals("Van Der Accentéd Chàractèrs") && toTest.getGivenName().equals("François")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,4 +56,3 @@ spring: | |
- AddSecHeaders | ||
httpclient.wiretap: true | ||
httpserver.wiretap: false | ||
|