mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-09-09 17:46:32 +00:00
ignore unknown fields during JWT deserialization
This commit is contained in:
@@ -38,7 +38,8 @@ open module org.cryptomator.desktop {
|
||||
requires ch.qos.logback.core;
|
||||
requires com.auth0.jwt;
|
||||
requires com.google.common;
|
||||
requires com.google.gson;
|
||||
requires com.fasterxml.jackson.databind;
|
||||
requires com.google.gson; // TODO replace with jackson?
|
||||
requires com.nimbusds.jose.jwt;
|
||||
requires com.nulabinc.zxcvbn;
|
||||
requires com.tobiasdiez.easybind;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package org.cryptomator.ui.keyloading.hub;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
// needs to be accessible by JSON decoder
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class HubConfig {
|
||||
|
||||
public String clientId;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.cryptomator.ui.keyloading.hub;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class HubConfigTest {
|
||||
|
||||
@Test
|
||||
@DisplayName("can parse JWT with unknown fields in header claim \"hub\"")
|
||||
public void testParseJWTWithUnknownFields() {
|
||||
var jwt = JWT.decode("eyJraWQiOiIxMjMiLCJ0eXAiOiJqd3QiLCJhbGciOiJIUzI1NiIsImh1YiI6eyJ1bmtub3duRmllbGQiOjQyLCJjbGllbnRJZCI6ImNyeXB0b21hdG9yIn19.eyJqdGkiOiI0NTYifQ.e1CStFf5fdh9ofX_6O8_LfbHfHEJZqUpuYNWz9xZp0I");
|
||||
var claim = jwt.getHeaderClaim("hub");
|
||||
var hubConfig = Assertions.assertDoesNotThrow(() -> claim.as(HubConfig.class));
|
||||
Assertions.assertEquals("cryptomator", hubConfig.clientId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user