Skip to content

Commit

Permalink
Send DeviceId to Hub during vault key retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Feb 19, 2025
1 parent 0ef83e8 commit 718cf32
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/cryptomator/hubcli/Backend.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public HttpResponse<String> grantAccess(UUID vaultId, Map<String, String> member
return sendRequest(httpClient, req, HttpResponse.BodyHandlers.ofString(StandardCharsets.UTF_8), 200, 409);
}

public HttpResponse<String> getAccessToken(UUID vaultId) throws IOException, InterruptedException, UnexpectedStatusCodeException {
var vaultKeyReq = createRequest("vaults/" + vaultId + "/access-token").GET().build();
public HttpResponse<String> getAccessToken(UUID vaultId, String deviceId) throws IOException, InterruptedException, UnexpectedStatusCodeException {
var vaultKeyReq = createRequest("vaults/" + vaultId + "/access-token").header("deviceId", deviceId).GET().build();
try {
return sendRequest(httpClient, vaultKeyReq, HttpResponse.BodyHandlers.ofString(StandardCharsets.US_ASCII), 200);
} catch (UnexpectedStatusCodeException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cryptomator/hubcli/VaultAddGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Integer call() throws Exception {

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

// get device info
var device = backend.getDeviceService().get(deviceId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cryptomator/hubcli/VaultAddUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Integer call() throws ParseException, GeneralSecurityException, Interrupt
var memberPublicKey = KeyHelper.readX509EncodedEcPublicKey(memberPublicKeyBytes);

// get vault key
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();

// get device info
var device = backend.getDeviceService().get(deviceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Integer call() throws IOException, InterruptedException, GeneralSecurityE
var vaultName = backend.getVaultService().get(vaultId).name();

// get vault key
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();

// get device info
var device = backend.getDeviceService().get(deviceId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cryptomator/hubcli/VaultRecoveryKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public Integer call() throws Exception {
var deviceId = KeyHelper.getKeyId(deviceKeyPair.getPublic());
try (var backend = new Backend(parentCmd.accessToken.value, parentCmd.common.getApiBase())) {
// get vault key
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId).body();
var vaultKeyJWE = backend.getVaultService().getAccessToken(vaultId, deviceId).body();

// get device info
var device = backend.getDeviceService().get(deviceId);
Expand Down

0 comments on commit 718cf32

Please sign in to comment.