Skip to content

Commit 718cf32

Browse files
committedFeb 19, 2025··
Send DeviceId to Hub during vault key retrieval
See cryptomator/hub#320
1 parent 0ef83e8 commit 718cf32

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed
 

‎src/main/java/org/cryptomator/hubcli/Backend.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ public HttpResponse<String> grantAccess(UUID vaultId, Map<String, String> member
100100
return sendRequest(httpClient, req, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8), 200, 409);
101101
}
102102

103-
public HttpResponse<String> getAccessToken(UUID vaultId) throws IOException, InterruptedException, UnexpectedStatusCodeException {
104-
var vaultKeyReq = createRequest("vaults/" + vaultId + "/access-token").GET().build();
103+
public HttpResponse<String> getAccessToken(UUID vaultId, String deviceId) throws IOException, InterruptedException, UnexpectedStatusCodeException {
104+
var vaultKeyReq = createRequest("vaults/" + vaultId + "/access-token").header("deviceId", deviceId).GET().build();
105105
try {
106106
return sendRequest(httpClient, vaultKeyReq, HttpResponse.BodyHandlers.ofString(StandardCharsets.US_ASCII), 200);
107107
} catch (UnexpectedStatusCodeException e) {

‎src/main/java/org/cryptomator/hubcli/VaultAddGroup.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public Integer call() throws Exception {
5252

5353
try (var backend = new Backend(parentCmd.accessToken.value, parentCmd.common.getApiBase())) {
5454
// get vault key
55-
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
55+
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();
5656

5757
// get device info
5858
var device = backend.getDeviceService().get(deviceId);

‎src/main/java/org/cryptomator/hubcli/VaultAddUser.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public Integer call() throws ParseException, GeneralSecurityException, Interrupt
6666
var memberPublicKey = KeyHelper.readX509EncodedEcPublicKey(memberPublicKeyBytes);
6767

6868
// get vault key
69-
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
69+
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();
7070

7171
// get device info
7272
var device = backend.getDeviceService().get(deviceId);

‎src/main/java/org/cryptomator/hubcli/VaultCreateTemplate.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public Integer call() throws IOException, InterruptedException, GeneralSecurityE
4545
var vaultName = backend.getVaultService().get(vaultId).name();
4646

4747
// get vault key
48-
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
48+
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();
4949

5050
// get device info
5151
var device = backend.getDeviceService().get(deviceId);

‎src/main/java/org/cryptomator/hubcli/VaultRecoveryKey.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Integer call() throws Exception {
3838
var deviceId = KeyHelper.getKeyId(deviceKeyPair.getPublic());
3939
try (var backend = new Backend(parentCmd.accessToken.value, parentCmd.common.getApiBase())) {
4040
// get vault key
41-
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
41+
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();
4242

4343
// get device info
4444
var device = backend.getDeviceService().get(deviceId);

0 commit comments

Comments
 (0)
Please sign in to comment.