-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from DiSSCo/feature/add-rbac
Put create/update/delete behind admin role
- Loading branch information
Showing
5 changed files
with
91 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# Date: Feb 27, 2024 | ||
# Notes: Issue with libexpat, parsing large tokens can trigger a denial of service | ||
# Needs to be fixed in Docker Image. | ||
CVE-2023-52425 | ||
# Date: March 21, 2024 | ||
# Issue: Vulnerability in spring-web | ||
# Solution: Spring boot needs to update its version of spring | ||
CVE-2024-22259 | ||
|
||
# Date: March 21, 2024 | ||
# Issue: Vulnerability in spring-security-core | ||
# Solution: Spring boot needs to update its version of spring | ||
CVE-2024-22257 |
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
58 changes: 58 additions & 0 deletions
58
src/test/java/eu/dissco/orchestration/backend/security/JwtAuthConverterTest.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,58 @@ | ||
package eu.dissco.orchestration.backend.security; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class JwtAuthConverterTest { | ||
|
||
private JwtAuthConverter converter; | ||
|
||
@BeforeEach | ||
void setup() { | ||
converter = new JwtAuthConverter(); | ||
} | ||
|
||
@Test | ||
void testEmptyToken() { | ||
// Given | ||
var jwt = new Jwt("SomeRandomStringWithTheFullValue", Instant.now(), Instant.now(), | ||
Map.of("kid", "SomeRandom", "typ", "JWT", "alg", "RS256"), | ||
Map.of("sub", "adf294ba-bb03-4962-8042-a37f1648458e")); | ||
|
||
// When | ||
var token = converter.convert(jwt); | ||
|
||
// Then | ||
assertThat(token.isAuthenticated()).isTrue(); | ||
assertThat(token.getName()).isEqualTo("adf294ba-bb03-4962-8042-a37f1648458e"); | ||
assertThat(token.getAuthorities()).isEmpty(); | ||
} | ||
|
||
@Test | ||
void testTokenRoles() { | ||
// Given | ||
var jwt = new Jwt("SomeRandomStringWithTheFullValue", Instant.now(), Instant.now(), | ||
Map.of("kid", "SomeRandom", "typ", "JWT", "alg", "RS256"), | ||
Map.of("sub", "adf294ba-bb03-4962-8042-a37f1648458e", | ||
"resource_access", Map.of("orchestration-service", | ||
Map.of("roles", List.of("orchestration-admin"))))); | ||
|
||
// When | ||
var token = converter.convert(jwt); | ||
|
||
// Then | ||
assertThat(token.isAuthenticated()).isTrue(); | ||
assertThat(token.getName()).isEqualTo("adf294ba-bb03-4962-8042-a37f1648458e"); | ||
assertThat(token.getAuthorities()).hasSize(1); | ||
} | ||
|
||
} |