-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/uvf
# Conflicts: # backend/src/main/resources/org/cryptomator/hub/flyway/ERM.png # frontend/src/common/jwt.ts # frontend/src/components/GrantPermissionDialog.vue # frontend/src/components/VaultDetails.vue # frontend/test/common/crypto.spec.ts
- Loading branch information
Showing
43 changed files
with
1,614 additions
and
204 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
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
62 changes: 62 additions & 0 deletions
62
backend/src/main/java/org/cryptomator/hub/api/SettingsResource.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,62 @@ | ||
package org.cryptomator.hub.api; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import jakarta.annotation.security.RolesAllowed; | ||
import jakarta.inject.Inject; | ||
import jakarta.transaction.Transactional; | ||
import jakarta.validation.Valid; | ||
import jakarta.validation.constraints.Max; | ||
import jakarta.validation.constraints.Min; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.PUT; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import org.cryptomator.hub.entities.Settings; | ||
import org.eclipse.microprofile.openapi.annotations.Operation; | ||
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse; | ||
|
||
@Path("/settings") | ||
public class SettingsResource { | ||
|
||
@Inject | ||
Settings.Repository settingsRepo; | ||
|
||
@GET | ||
@RolesAllowed("user") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Operation(summary = "get the billing information") | ||
@APIResponse(responseCode = "200") | ||
@Transactional | ||
public SettingsDto get() { | ||
return SettingsDto.fromEntity(settingsRepo.get()); | ||
} | ||
|
||
@PUT | ||
@RolesAllowed("admin") | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@Operation(summary = "update settings") | ||
@APIResponse(responseCode = "204", description = "token set") | ||
@APIResponse(responseCode = "400", description = "invalid settings") | ||
@APIResponse(responseCode = "403", description = "only admins are allowed to update settings") | ||
@Transactional | ||
public Response put(@NotNull @Valid SettingsDto dto) { | ||
var settings = settingsRepo.get(); | ||
settings.setWotMaxDepth(dto.wotMaxDepth); | ||
settings.setWotIdVerifyLen(dto.wotIdVerifyLen); | ||
settingsRepo.persist(settings); | ||
return Response.status(Response.Status.NO_CONTENT).build(); | ||
} | ||
|
||
public record SettingsDto(@JsonProperty("hubId") String hubId, @JsonProperty("wotMaxDepth") @Min(0) @Max(9) int wotMaxDepth, @JsonProperty("wotIdVerifyLen") @Min(0) int wotIdVerifyLen) { | ||
|
||
public static SettingsDto fromEntity(Settings entity) { | ||
return new SettingsDto(entity.getHubId(), entity.getWotMaxDepth(), entity.getWotIdVerifyLen()); | ||
} | ||
|
||
} | ||
|
||
} |
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
108 changes: 108 additions & 0 deletions
108
backend/src/main/java/org/cryptomator/hub/entities/EffectiveWot.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,108 @@ | ||
package org.cryptomator.hub.entities; | ||
|
||
import io.quarkus.hibernate.orm.panache.PanacheQuery; | ||
import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase; | ||
import io.quarkus.panache.common.Parameters; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
import jakarta.persistence.EmbeddedId; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.NamedQuery; | ||
import jakarta.persistence.Table; | ||
import org.hibernate.annotations.Immutable; | ||
import org.hibernate.annotations.Type; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
@Immutable | ||
@Table(name = "effective_wot") | ||
@NamedQuery(name = "EffectiveWot.findTrustedUsers", query = """ | ||
SELECT wot | ||
FROM EffectiveWot wot | ||
WHERE wot.id.trustingUserId = :trustingUserId | ||
""") | ||
@NamedQuery(name = "EffectiveWot.findTrustedUser", query = """ | ||
SELECT wot | ||
FROM EffectiveWot wot | ||
WHERE wot.id.trustingUserId = :trustingUserId AND wot.id.trustedUserId = :trustedUserId | ||
""") | ||
public class EffectiveWot { | ||
|
||
@EmbeddedId | ||
private Id id; | ||
|
||
@Column(name = "signature_chain") | ||
@Type(StringArrayType.class) | ||
private String[] signatureChain; | ||
|
||
public Id getId() { | ||
return id; | ||
} | ||
|
||
public void setId(Id id) { | ||
this.id = id; | ||
} | ||
|
||
public String[] getSignatureChain() { | ||
return signatureChain; | ||
} | ||
|
||
public void setSignatureChain(String[] signatureChain) { | ||
this.signatureChain = signatureChain; | ||
} | ||
|
||
@Embeddable | ||
public static class Id implements Serializable { | ||
|
||
@Column(name = "trusting_user_id") | ||
private String trustingUserId; | ||
|
||
@Column(name = "trusted_user_id") | ||
private String trustedUserId; | ||
|
||
public String getTrustingUserId() { | ||
return trustingUserId; | ||
} | ||
|
||
public String getTrustedUserId() { | ||
return trustedUserId; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o instanceof Id other) { | ||
return Objects.equals(trustingUserId, other.trustingUserId) // | ||
&& Objects.equals(trustedUserId, other.trustedUserId); | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(trustingUserId, trustedUserId); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "EffectiveWotId{" + | ||
"trustingUserId='" + trustingUserId + '\'' + | ||
", trustedUserId='" + trustedUserId + '\'' + | ||
'}'; | ||
} | ||
} | ||
|
||
@ApplicationScoped | ||
public static class Repository implements PanacheRepositoryBase<EffectiveWot, Id> { | ||
public PanacheQuery<EffectiveWot> findTrusted(String trustingUserId) { | ||
return find("#EffectiveWot.findTrustedUsers", Parameters.with("trustingUserId", trustingUserId)); | ||
} | ||
|
||
public PanacheQuery<EffectiveWot> findTrusted(String trustingUserId, String trustedUserId) { | ||
return find("#EffectiveWot.findTrustedUser", Parameters.with("trustingUserId", trustingUserId).and("trustedUserId", trustedUserId)); | ||
} | ||
} | ||
} |
Oops, something went wrong.