aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/com/zeapo/pwdstore/git/operation
diff options
context:
space:
mode:
authorFabian Henneke <FabianHenneke@users.noreply.github.com>2020-09-08 12:08:06 +0200
committerGitHub <noreply@github.com>2020-09-08 15:38:06 +0530
commit9e0fb93f910bd1e890103d44fda56f52ab5c821e (patch)
treec0697532439964efb11cf3369629fc92457d79e4 /app/src/main/java/com/zeapo/pwdstore/git/operation
parentff780b02de77ae0adde23e57d9cc3245552c0f1c (diff)
downloadHardenedPass-9e0fb93f910bd1e890103d44fda56f52ab5c821e.tar.gz
HardenedPass-9e0fb93f910bd1e890103d44fda56f52ab5c821e.zip
Support multiple authentication methods (#825)
* Offer password SSH authentication after publickey * git: re-add back button handling Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Hide unsupported authentication methods Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * GitCommandExecutor: cleanup and address build warning Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Address review comments Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * DecryptActivity: hide menu items until decrypt finishes Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> * Add changelog entry Signed-off-by: Harsh Shandilya <me@msfjarvis.dev> Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'app/src/main/java/com/zeapo/pwdstore/git/operation')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt20
1 files changed, 8 insertions, 12 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt b/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt
index ad6a3e29..85c38c6a 100644
--- a/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/git/operation/GitOperation.kt
@@ -19,7 +19,7 @@ import com.zeapo.pwdstore.UserPreference
import com.zeapo.pwdstore.git.GitCommandExecutor
import com.zeapo.pwdstore.git.config.AuthMode
import com.zeapo.pwdstore.git.config.GitSettings
-import com.zeapo.pwdstore.git.sshj.SshAuthData
+import com.zeapo.pwdstore.git.sshj.SshAuthMethod
import com.zeapo.pwdstore.git.sshj.SshKey
import com.zeapo.pwdstore.git.sshj.SshjSessionFactory
import com.zeapo.pwdstore.utils.BiometricAuthenticator
@@ -99,8 +99,8 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
}
}
- private fun registerAuthProviders(authData: SshAuthData, credentialsProvider: CredentialsProvider? = null) {
- sshSessionFactory = SshjSessionFactory(authData, hostKeyFile)
+ private fun registerAuthProviders(authMethod: SshAuthMethod, credentialsProvider: CredentialsProvider? = null) {
+ sshSessionFactory = SshjSessionFactory(authMethod, hostKeyFile)
commands.filterIsInstance<TransportCommand<*, *>>().forEach { command ->
command.setTransportConfigCallback { transport: Transport ->
(transport as? SshTransport)?.sshSessionFactory = sshSessionFactory
@@ -154,8 +154,7 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
}
when (result) {
is BiometricAuthenticator.Result.Success -> {
- registerAuthProviders(
- SshAuthData.SshKey(CredentialFinder(callingActivity, AuthMode.SshKey)))
+ registerAuthProviders(SshAuthMethod.SshKey(callingActivity))
}
is BiometricAuthenticator.Result.Cancelled -> {
return Err(SSHException(DisconnectReason.AUTH_CANCELLED_BY_USER))
@@ -173,7 +172,7 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
}
}
} else {
- registerAuthProviders(SshAuthData.SshKey(CredentialFinder(callingActivity, AuthMode.SshKey)))
+ registerAuthProviders(SshAuthMethod.SshKey(callingActivity))
}
} else {
onMissingSshKeyFile()
@@ -181,13 +180,10 @@ abstract class GitOperation(protected val callingActivity: FragmentActivity) {
// error, allowing users to make the SSH key selection.
return Err(SSHException(DisconnectReason.AUTH_CANCELLED_BY_USER))
}
- AuthMode.OpenKeychain -> registerAuthProviders(SshAuthData.OpenKeychain(callingActivity))
+ AuthMode.OpenKeychain -> registerAuthProviders(SshAuthMethod.OpenKeychain(callingActivity))
AuthMode.Password -> {
- val credentialFinder = CredentialFinder(callingActivity, AuthMode.Password)
- val httpsCredentialProvider = HttpsCredentialsProvider(credentialFinder)
- registerAuthProviders(
- SshAuthData.Password(CredentialFinder(callingActivity, AuthMode.Password)),
- httpsCredentialProvider)
+ val httpsCredentialProvider = HttpsCredentialsProvider(CredentialFinder(callingActivity, AuthMode.Password))
+ registerAuthProviders(SshAuthMethod.Password(callingActivity), httpsCredentialProvider)
}
AuthMode.None -> {
}