-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump jjwt.version from 0.11.5 to 0.12.5 (#17075)
* Bump jjwt.version from 0.11.5 to 0.12.3 Bumps `jjwt.version` from 0.11.5 to 0.12.3. Updates `io.jsonwebtoken:jjwt-api` from 0.11.5 to 0.12.3 - [Release notes](https://github.com/jwtk/jjwt/releases) - [Changelog](https://github.com/jwtk/jjwt/blob/master/CHANGELOG.md) - [Commits](jwtk/jjwt@0.11.5...0.12.3) Updates `io.jsonwebtoken:jjwt-impl` from 0.11.5 to 0.12.3 - [Release notes](https://github.com/jwtk/jjwt/releases) - [Changelog](https://github.com/jwtk/jjwt/blob/master/CHANGELOG.md) - [Commits](jwtk/jjwt@0.11.5...0.12.3) Updates `io.jsonwebtoken:jjwt-jackson` from 0.11.5 to 0.12.3 --- updated-dependencies: - dependency-name: io.jsonwebtoken:jjwt-api dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.jsonwebtoken:jjwt-impl dependency-type: direct:production update-type: version-update:semver-minor - dependency-name: io.jsonwebtoken:jjwt-jackson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fixed JwtTokenValidator * adapt jwt token test for NONE alg * trim imported licenses in integration tests * Added changelog * Added changelog * code cleanup, removed changelog, added test * code cleanup * Update to jjwt 0.12.5 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tomas Dvorak <[email protected]> Co-authored-by: Bernd Ahlers <[email protected]> Co-authored-by: Bernd Ahlers <[email protected]>
- Loading branch information
1 parent
527da6b
commit 54ff42b
Showing
7 changed files
with
102 additions
and
103 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
68 changes: 68 additions & 0 deletions
68
data-node/src/test/java/org/graylog/datanode/initializers/JwtTokenValidatorTest.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,68 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
package org.graylog.datanode.initializers; | ||
|
||
import com.github.joschi.jadconfig.util.Duration; | ||
import org.assertj.core.api.Assertions; | ||
import org.graylog2.security.IndexerJwtAuthTokenProvider; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.Base64; | ||
|
||
class JwtTokenValidatorTest { | ||
|
||
@Test | ||
void verifyValidToken() throws TokenVerificationException { | ||
final String key = "gTVfiF6A0pB70A3UP1EahpoR6LId9DdNadIkYNygK5Z8lpeJIpw9vN0jZ6fdsfeuV9KIg9gVLkCHIPj6FHW5Q9AvpOoGZO3h"; | ||
final JwtTokenValidator validator = new JwtTokenValidator(key); | ||
validator.verifyToken(generateToken(key)); | ||
} | ||
|
||
@Test | ||
void verifyInvalidToken() { | ||
final String generationKey = "gTVfiF6A0pB70A3UP1EahpoR6LId9DdNadIkYNygK5Z8lpeJIpw9vN0jZ6fdsfeuV9KIg9gVLkCHIPj6FHW5Q9AvpOoGZO3h"; | ||
final String verificationKey = "n51wcO3jn8w3JNyGgKc7k1fTCr1FWvGg7ODfQOyBT2fizBrCVsRJg2GsbYGLNejfi3QsKaqJgo3zAWMuAZhJznuizHZpv92S"; | ||
final JwtTokenValidator validator = new JwtTokenValidator(verificationKey); | ||
Assertions.assertThatThrownBy(() -> validator.verifyToken(generateToken(generationKey))) | ||
.isInstanceOf(TokenVerificationException.class) | ||
.hasMessageContaining("JWT signature does not match locally computed signature"); | ||
} | ||
|
||
@Test | ||
void testNoneAlgorithm() { | ||
final String key = "gTVfiF6A0pB70A3UP1EahpoR6LId9DdNadIkYNygK5Z8lpeJIpw9vN0jZ6fdsfeuV9KIg9gVLkCHIPj6FHW5Q9AvpOoGZO3h"; | ||
final JwtTokenValidator validator = new JwtTokenValidator(key); | ||
Assertions.assertThatThrownBy(() -> validator.verifyToken(removeSignature(generateToken(key)))) | ||
.isInstanceOf(TokenVerificationException.class) | ||
.hasMessageContaining("Token format/configuration is not supported"); | ||
} | ||
|
||
private String removeSignature(String token) { | ||
final String header = Base64.getEncoder() | ||
.encodeToString("{\"alg\": \"none\"}" | ||
.getBytes(StandardCharsets.UTF_8)); | ||
|
||
return header + token.substring(token.indexOf('.'), token.lastIndexOf('.') + 1); | ||
} | ||
|
||
@NotNull | ||
private static String generateToken(String signingKey) { | ||
return IndexerJwtAuthTokenProvider.createToken(signingKey.getBytes(StandardCharsets.UTF_8), Duration.seconds(180)); | ||
} | ||
} |
62 changes: 0 additions & 62 deletions
62
data-node/src/test/java/org/graylog/datanode/initializers/JwtTokenVerifierTest.java
This file was deleted.
Oops, something went wrong.
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