Skip to content

Commit 6e2e09b

Browse files
committed
Add vault metadata WiP (#19).
1 parent cb2327a commit 6e2e09b

29 files changed

Lines changed: 515 additions & 193 deletions

backend/setup/aws_sts/createbucketpermissionpolicy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"s3:PutObject"
2222
],
2323
"Resource": [
24-
"arn:aws:s3:::cipherduck*/vault.cryptomator",
24+
"arn:aws:s3:::cipherduck*/vault.uvf",
2525
"arn:aws:s3:::cipherduck*/*/"
2626
]
2727
}

backend/setup/minio_sts/createbucketpolicy.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
],
2121
"Resource": [
2222
"arn:aws:s3:::cipherduck*/*/",
23-
"arn:aws:s3:::cipherduck*/vault.cryptomator"
23+
"arn:aws:s3:::cipherduck*/vault.uvf"
2424
]
2525
}
2626
]

backend/src/main/java/org/cryptomator/hub/api/VaultResource.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ public Response createOrUpdate(@PathParam("vaultId") UUID vaultId, @Valid @NotNu
441441
vault.description = vaultDto.description;
442442
vault.archived = existingVault.isEmpty() ? false : vaultDto.archived;
443443

444+
// / start cipherduck extension
445+
vault.metadata = vaultDto.metadata;
446+
// \ end cipherduck extension
447+
444448
vault.persistAndFlush(); // trigger PersistenceException before we continue with
445449
if (existingVault.isEmpty()) {
446450
var access = new VaultAccess();
@@ -525,10 +529,17 @@ public record VaultDto(@JsonProperty("id") UUID id,
525529
@JsonProperty("masterkey") @OnlyBase64Chars String masterkey, @JsonProperty("iterations") Integer iterations,
526530
@JsonProperty("salt") @OnlyBase64Chars String salt,
527531
@JsonProperty("authPublicKey") @OnlyBase64Chars String authPublicKey, @JsonProperty("authPrivateKey") @OnlyBase64Chars String authPrivateKey
532+
// / start cipherduck extension
533+
,@JsonProperty("metadata") @NotNull String metadata
534+
// \ end cipherduck extension
528535
) {
529536

530537
public static VaultDto fromEntity(Vault entity) {
531-
return new VaultDto(entity.id, entity.name, entity.description, entity.archived, entity.creationTime.truncatedTo(ChronoUnit.MILLIS), entity.masterkey, entity.iterations, entity.salt, entity.authenticationPublicKey, entity.authenticationPrivateKey);
538+
return new VaultDto(entity.id, entity.name, entity.description, entity.archived, entity.creationTime.truncatedTo(ChronoUnit.MILLIS), entity.masterkey, entity.iterations, entity.salt, entity.authenticationPublicKey, entity.authenticationPrivateKey
539+
// / start cipherduck extension
540+
, entity.metadata
541+
// \ end cipherduck extension
542+
);
532543
}
533544

534545
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.cryptomator.hub.api.cipherduck;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
5+
import java.util.UUID;
6+
7+
public record CreateS3STSBucketDto(
8+
@JsonProperty("vaultId")
9+
String vaultId,
10+
@JsonProperty("storageConfigId")
11+
UUID storageConfigId,
12+
@JsonProperty("vaultUvf")
13+
String vaultUvf,
14+
@JsonProperty("rootDirHash")
15+
String rootDirHash,
16+
@JsonProperty("awsAccessKey")
17+
String awsAccessKey,
18+
@JsonProperty("awsSecretKey")
19+
String awsSecretKey,
20+
@JsonProperty("sessionToken")
21+
String sessionToken,
22+
@JsonProperty("region")
23+
String region
24+
) {
25+
26+
}
27+

backend/src/main/java/org/cryptomator/hub/api/cipherduck/StorageDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public record StorageDto(
99
String vaultId,
1010
@JsonProperty("storageConfigId")
1111
UUID storageConfigId,
12-
@JsonProperty("vaultConfigToken")
12+
@JsonProperty("vaultUvf")
1313
String vaultConfigToken,
1414
@JsonProperty("rootDirHash")
1515
String rootDirHash,

backend/src/main/java/org/cryptomator/hub/api/cipherduck/StorageProfileResource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.List;
2828
import java.util.UUID;
2929
import java.util.stream.Collectors;
30-
import java.util.stream.Stream;
3130

3231
@Path("/storageprofile")
3332
public class StorageProfileResource {
@@ -137,7 +136,7 @@ public Response archive(@PathParam("profileId") UUID profileId, @FormParam("arch
137136
@Transactional
138137
@Operation(summary = "get configs for storage backends", description = "get list of configs for storage backends")
139138
@APIResponse(responseCode = "200", description = "uploaded storage configuration")
140-
public VaultJWEPayloadDto getVaultJWEBackendDto(final StorageProfileDto.Protocol protocol) {
139+
public VaultMasterkeyJWEDto getVaultJWEBackendDto(final StorageProfileDto.Protocol protocol) {
141140
// N.B. temporary workaround to have VaultJWEBackendDto exposed in openapi.json for now....
142141
return null;
143142
}

backend/src/main/java/org/cryptomator/hub/api/cipherduck/StorageProfileS3Dto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public enum S3_STORAGE_CLASSES {
3535
@Schema(description = "Whether to use path style for S3 endpoint for template upload/bucket creation.", example = "false", defaultValue = "false")
3636
Boolean withPathStyleAccessEnabled = false;
3737

38-
@JsonProperty(value = "storageClass")
38+
@JsonProperty(value = "storageClass", defaultValue = "STANDARD")
3939
@Schema(description = "Storage class for upload. Defaults to STANDARD", example = "STANDARD", required = true)
4040
S3_STORAGE_CLASSES storageClass = S3_STORAGE_CLASSES.STANDARD;
4141

backend/src/main/java/org/cryptomator/hub/api/cipherduck/StorageProfileS3STSDto.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public enum S3_SERVERSIDE_ENCRYPTION {
3434
String stsRoleArnClient;
3535

3636
@JsonProperty(value = "stsRoleArnHub", required = true)
37-
@Schema(description = "STS role for frontend to assume to create buckets (used with inline policy and passed to hub backend). Will be the same as stsRoleArnClient for AWS, different for MinIO.", example = "arn:aws:iam::<ACCOUNT ID>:role/cipherduck-createbucket")
37+
@Schema(description = "STS role for frontend to assume to create buckets (used with inline policy and passed to hub storage). Will be the same as stsRoleArnClient for AWS, different for MinIO.", example = "arn:aws:iam::<ACCOUNT ID>:role/cipherduck-createbucket")
3838
String stsRoleArnHub;
3939

4040
@JsonProperty("stsEndpoint")
41-
@Schema(description = "STS endpoint to use for AssumeRoleWithWebIdentity and AssumeRole for getting a temporary access token passed to the backend. Defaults to AWS SDK default.", nullable = true)
41+
@Schema(description = "STS endpoint to use for AssumeRoleWithWebIdentity and AssumeRole for getting a temporary access token passed to the storage. Defaults to AWS SDK default.", nullable = true)
4242
String stsEndpoint;
4343

4444
@JsonProperty(value = "bucketVersioning", defaultValue = "true", required = true)

backend/src/main/java/org/cryptomator/hub/api/cipherduck/StorageResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class StorageResource {
5555
@APIResponse(responseCode = "400", description = "Could not create bucket")
5656
@APIResponse(responseCode = "409", description = "Vault with this ID or bucket with this name already exists")
5757
@APIResponse(responseCode = "410", description = "Storage profile is archived")
58-
public Response createBucket(@PathParam("vaultId") UUID vaultId, final StorageDto storage) {
58+
public Response createBucket(@PathParam("vaultId") UUID vaultId, final CreateS3STSBucketDto storage) {
5959
Optional<Vault> vault = Vault.<Vault>findByIdOptional(vaultId);
6060
if (vault.isPresent()) {
6161
throw new ClientErrorException(String.format("Vault with ID %s already exists", vaultId), Response.Status.CONFLICT);

backend/src/main/java/org/cryptomator/hub/api/cipherduck/VaultJWEBackendDto.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/**
66
* Part of vault JWE specifying the vault bookmark.
77
* Allows to create a bookmark in the client referencing the vendor in the storage profiles.
8-
* This Java record is unused in hub, only its ts counterpart in `backend.ts`.
8+
* This Java record is unused in hub, only its ts counterpart in `storage.ts`.
99
* It will used in Cipherduck client in the OpenAPI generator.
1010
*/
1111
public record VaultJWEBackendDto(

0 commit comments

Comments
 (0)