This commit is contained in:
crschnick
2025-05-27 13:13:26 +00:00
parent 495fc07714
commit 9e2726b66f
5 changed files with 55 additions and 9 deletions
@@ -1,6 +1,7 @@
package io.xpipe.app.password;
import io.xpipe.core.process.OsType;
import io.xpipe.core.util.SecretValue;
import io.xpipe.core.util.ValidationException;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
@@ -29,6 +30,12 @@ public interface PasswordManager {
return l;
}
static class CredentialResult {
String username;
SecretValue password;
}
default void checkComplete() throws ValidationException {}
String retrievePassword(String key);
@@ -15,7 +15,7 @@ import lombok.experimental.SuperBuilder;
@Getter
public abstract class IdentityStore implements SelfReferentialStore, DataStore {
String username;
public abstract String getUsername();
public abstract SecretRetrievalStrategy getPassword();
@@ -30,8 +30,4 @@ public abstract class IdentityStore implements SelfReferentialStore, DataStore {
getSshIdentity().checkComplete();
}
}
abstract EncryptedValue<SecretRetrievalStrategy> getEncryptedPassword();
abstract EncryptedValue<SshIdentityStrategy> getEncryptedSshIdentity();
}
@@ -18,6 +18,7 @@ import lombok.extern.jackson.Jacksonized;
@ToString(callSuper = true)
public class LocalIdentityStore extends IdentityStore {
String username;
EncryptedValue<SecretRetrievalStrategy> password;
EncryptedValue<SshIdentityStrategy> sshIdentity;
@@ -31,12 +32,10 @@ public class LocalIdentityStore extends IdentityStore {
return sshIdentity != null ? sshIdentity.getValue() : null;
}
@Override
EncryptedValue<SecretRetrievalStrategy> getEncryptedPassword() {
return password;
}
@Override
EncryptedValue<SshIdentityStrategy> getEncryptedSshIdentity() {
return sshIdentity;
}
@@ -0,0 +1,45 @@
package io.xpipe.ext.base.identity;
import com.fasterxml.jackson.annotation.JsonTypeName;
import io.xpipe.app.util.EncryptedValue;
import io.xpipe.app.util.SecretQuery;
import io.xpipe.app.util.SecretRetrievalStrategy;
import io.xpipe.core.store.InternalCacheDataStore;
import io.xpipe.core.store.StatefulDataStore;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.Value;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;
@SuperBuilder
@JsonTypeName("passwordManagerIdentity")
@Jacksonized
@Value
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PasswordManagerIdentityStore extends IdentityStore implements InternalCacheDataStore {
String key;
@Override
public String getUsername() {
return "";
}
@Override
public SecretRetrievalStrategy getPassword() {
return new SecretRetrievalStrategy() {
@Override
public SecretQuery query() {
return null;
}
};
}
@Override
public SshIdentityStrategy getSshIdentity() {
return null;
}
}
@@ -20,6 +20,7 @@ import lombok.extern.jackson.Jacksonized;
@Jacksonized
public class SyncedIdentityStore extends IdentityStore implements UserScopeStore {
String username;
// We can encrypt it with only the vault key as
// per user stores are additionally encrypted on the entry level
EncryptedValue.VaultKey<SecretRetrievalStrategy> password;
@@ -46,12 +47,10 @@ public class SyncedIdentityStore extends IdentityStore implements UserScopeStore
}
}
@Override
EncryptedValue.VaultKey<SecretRetrievalStrategy> getEncryptedPassword() {
return password;
}
@Override
EncryptedValue.VaultKey<SshIdentityStrategy> getEncryptedSshIdentity() {
return sshIdentity;
}