-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement sharing vaults with groups and unsharing with users/groups;…
- Loading branch information
Showing
13 changed files
with
600 additions
and
76 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
72 changes: 72 additions & 0 deletions
72
backend/src/main/java/org/cryptomator/hub/api/cipherduck/CipherduckConfig.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,72 @@ | ||
package org.cryptomator.hub.api.cipherduck; | ||
|
||
import io.quarkus.oidc.OidcConfigurationMetadata; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@ApplicationScoped | ||
public class CipherduckConfig { | ||
@Inject | ||
@ConfigProperty(name = "hub.keycloak.public-url", defaultValue = "") | ||
String keycloakPublicUrl; | ||
|
||
@Inject | ||
@ConfigProperty(name = "hub.keycloak.realm", defaultValue = "") | ||
String keycloakRealm; | ||
|
||
|
||
|
||
@Inject | ||
@ConfigProperty(name = "quarkus.oidc.client-id", defaultValue = "") | ||
String keycloakClientIdHub; | ||
|
||
@Inject | ||
@ConfigProperty(name = "hub.keycloak.oidc.cryptomator-client-id", defaultValue = "") | ||
String keycloakClientIdCryptomator; | ||
|
||
@Inject | ||
@ConfigProperty(name = "quarkus.oidc.auth-server-url") | ||
String internalRealmUrl; | ||
|
||
@Inject | ||
OidcConfigurationMetadata oidcConfData; | ||
|
||
String replacePrefix(String str, String prefix, String replacement) { | ||
int index = str.indexOf(prefix); | ||
if (index == 0) { | ||
return replacement + str.substring(prefix.length()); | ||
} else { | ||
return str; | ||
} | ||
} | ||
|
||
String trimTrailingSlash(String str) { | ||
if (str.endsWith("/")) { | ||
return str.substring(0, str.length() - 1); | ||
} else { | ||
return str; | ||
} | ||
|
||
} | ||
public String keycloakClientIdHub() { | ||
return keycloakClientIdHub; | ||
} | ||
|
||
public String keycloakClientIdCryptomator() { | ||
return keycloakClientIdCryptomator; | ||
} | ||
public String publicRealmUri() { | ||
return trimTrailingSlash(keycloakPublicUrl + "/realms/" + keycloakRealm); | ||
} | ||
|
||
public String authEndpoint() { | ||
return replacePrefix(oidcConfData.getAuthorizationUri(), trimTrailingSlash(internalRealmUrl), publicRealmUri()); | ||
} | ||
|
||
public String tokenEndpoint() { | ||
return replacePrefix(oidcConfData.getTokenUri(), trimTrailingSlash(internalRealmUrl), publicRealmUri()); | ||
} | ||
|
||
|
||
} |
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
102 changes: 102 additions & 0 deletions
102
backend/src/main/java/org/cryptomator/hub/api/cipherduck/VaultJWEBackendDto.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,102 @@ | ||
package org.cryptomator.hub.api.cipherduck; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Optional; | ||
|
||
public record VaultJWEBackendDto( | ||
|
||
// (1) protocol | ||
// (1a) protocol hub-independent | ||
Optional<String> authorization, | ||
|
||
|
||
Optional<String> oauthRedirectUrl, | ||
|
||
Optional<String> usernameConfigurable, | ||
|
||
Optional<String> passwordConfigurable, | ||
|
||
Optional<String> tokenConfigurable, | ||
|
||
|
||
// (1b) protocol hub-specific | ||
Optional<String> oauthAuthorizationUrl, | ||
|
||
@JsonProperty("oAuthTokenUrl") | ||
Optional<String> oauthTokenUrl, | ||
|
||
Optional<String> oauthClientId, | ||
|
||
|
||
// (1c) protocol storage-specific | ||
Optional<String> protocol, | ||
|
||
Optional<String> vendor, | ||
|
||
Optional<String> region, | ||
|
||
Optional<String> stsEndpoint, | ||
|
||
Optional<String> scheme, | ||
|
||
|
||
// (2) bookmark aka. Host | ||
// (2a) bookmark direct fields | ||
Optional<String> hostname, | ||
|
||
Optional<Integer> port, | ||
|
||
Optional<String> defaultPath, | ||
|
||
Optional<String> nickname, | ||
|
||
Optional<String> uuid, | ||
|
||
|
||
// (2b) boookmark custom properties | ||
Optional<String> stsRoleArn, | ||
|
||
Optional<String> stsRoleArn2, | ||
|
||
Optional<Integer> stsDurationSeconds, | ||
|
||
Optional<String> parentUUID, | ||
|
||
Optional<String> oAuthTokenExchangeAudience, | ||
|
||
|
||
// (3) keychain credentials | ||
Optional<String> username, | ||
|
||
Optional<String> password) implements VaultJWEBackend { | ||
|
||
|
||
public VaultJWEBackendDto(VaultJWEBackend s, final String oAuthAuthorizationUrl, final String oAuthTokenUrl, final String oAuthClientId, final String oAuthTokenExchangeAudience) { | ||
this(s.authorization(), | ||
s.oauthRedirectUrl(), | ||
s.usernameConfigurable(), | ||
s.passwordConfigurable(), | ||
s.tokenConfigurable(), | ||
Optional.of(oAuthAuthorizationUrl), | ||
Optional.of(oAuthTokenUrl), | ||
Optional.of(oAuthClientId), | ||
s.protocol(), | ||
s.vendor(), | ||
s.region(), | ||
s.stsEndpoint(), | ||
s.scheme(), | ||
s.hostname(), | ||
s.port(), | ||
s.defaultPath(), | ||
s.nickname(), | ||
s.uuid(), | ||
s.stsRoleArn(), | ||
s.stsRoleArn2(), | ||
s.stsDurationSeconds(), | ||
s.parentUUID(), | ||
Optional.of(oAuthTokenExchangeAudience), | ||
s.username(), | ||
s.password()); | ||
} | ||
} |
Oops, something went wrong.