mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 22:05:19 +00:00
Remember HTTPS password throughout a sync operation (#1062)
* Remember HTTPS password throughout a sync operation * Add CHANGELOG.md entry Co-authored-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
@@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
- Password creation UI will scroll if it does not fit on the screen
|
- Password creation UI will scroll if it does not fit on the screen
|
||||||
- Git server protocol and authentication mode are only updated when explicitly saved
|
- Git server protocol and authentication mode are only updated when explicitly saved
|
||||||
|
- Remember HTTPS password during a sync operation
|
||||||
- Delete stored HTTPS password on connection errors (such as failed authentication)
|
- Delete stored HTTPS password on connection errors (such as failed authentication)
|
||||||
|
|
||||||
## [1.11.2] - 2020-08-24
|
## [1.11.2] - 2020-08-24
|
||||||
|
@@ -50,7 +50,9 @@ abstract class GitOperation(gitDir: File, internal val callingActivity: Fragment
|
|||||||
protected val git = Git(repository)
|
protected val git = Git(repository)
|
||||||
protected val remoteBranch = GitSettings.branch
|
protected val remoteBranch = GitSettings.branch
|
||||||
|
|
||||||
private class PasswordFinderCredentialsProvider(private val passwordFinder: PasswordFinder) : CredentialsProvider() {
|
private class HttpsCredentialsProvider(private val passwordFinder: PasswordFinder) : CredentialsProvider() {
|
||||||
|
|
||||||
|
private var cachedPassword: CharArray? = null
|
||||||
|
|
||||||
override fun isInteractive() = true
|
override fun isInteractive() = true
|
||||||
|
|
||||||
@@ -58,7 +60,11 @@ abstract class GitOperation(gitDir: File, internal val callingActivity: Fragment
|
|||||||
for (item in items) {
|
for (item in items) {
|
||||||
when (item) {
|
when (item) {
|
||||||
is CredentialItem.Username -> item.value = uri?.user
|
is CredentialItem.Username -> item.value = uri?.user
|
||||||
is CredentialItem.Password -> item.value = passwordFinder.reqPassword(null)
|
is CredentialItem.Password -> {
|
||||||
|
item.value = cachedPassword?.clone() ?: passwordFinder.reqPassword(null).also {
|
||||||
|
cachedPassword = it.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
else -> UnsupportedCredentialItem(uri, item.javaClass.name)
|
else -> UnsupportedCredentialItem(uri, item.javaClass.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,12 +74,17 @@ abstract class GitOperation(gitDir: File, internal val callingActivity: Fragment
|
|||||||
override fun supports(vararg items: CredentialItem) = items.all {
|
override fun supports(vararg items: CredentialItem) = items.all {
|
||||||
it is CredentialItem.Username || it is CredentialItem.Password
|
it is CredentialItem.Username || it is CredentialItem.Password
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun reset(uri: URIish?) {
|
||||||
|
cachedPassword?.fill(0.toChar())
|
||||||
|
cachedPassword = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun withPasswordAuthentication(passwordFinder: InteractivePasswordFinder): GitOperation {
|
private fun withPasswordAuthentication(passwordFinder: InteractivePasswordFinder): GitOperation {
|
||||||
val sessionFactory = SshjSessionFactory(SshAuthData.Password(passwordFinder), hostKeyFile)
|
val sessionFactory = SshjSessionFactory(SshAuthData.Password(passwordFinder), hostKeyFile)
|
||||||
SshSessionFactory.setInstance(sessionFactory)
|
SshSessionFactory.setInstance(sessionFactory)
|
||||||
this.provider = PasswordFinderCredentialsProvider(passwordFinder)
|
this.provider = HttpsCredentialsProvider(passwordFinder)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user