mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-24 02:51:34 -08:00
fix: Select passkey in passwordless mode #2282
This commit is contained in:
8 files changed
+91
-14
No files matched your search
@@ -29,6 +29,7 @@ import com.kunzisoft.keepass.model.AppOriginEntryField.isAppIdSignature
|
||||
import com.kunzisoft.keepass.model.AppOriginEntryField.isWebDomain
|
||||
import com.kunzisoft.keepass.model.PasskeyEntryFields.isPasskey
|
||||
import com.kunzisoft.keepass.model.PasskeyEntryFields.isRelyingParty
|
||||
import com.kunzisoft.keepass.model.PasskeyEntryFields.isCredentialId
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields.isOTP
|
||||
import com.kunzisoft.keepass.otp.OtpEntryFields.isOTPURIField
|
||||
import com.kunzisoft.keepass.utils.UUIDUtils.asHexString
|
||||
@@ -176,11 +177,33 @@ class SearchHelper {
|
||||
}
|
||||
}
|
||||
if (searchParameters.searchInRelyingParty) {
|
||||
if(entry.getExtraFields().any { field ->
|
||||
val relyingParty = searchParameters.searchQuery
|
||||
val credentialId = searchParameters.searchOption
|
||||
val containsRelyingParty = entry.getExtraFields().any { field ->
|
||||
field.isRelyingParty()
|
||||
&& checkSearchQuery(field.protectedValue.stringValue, searchParameters)
|
||||
})
|
||||
return true
|
||||
&& checkSearchQuery(
|
||||
stringToCheck = field.protectedValue.stringValue,
|
||||
searchParameters = SearchParameters().apply {
|
||||
searchQuery = relyingParty
|
||||
searchInRelyingParty = true
|
||||
caseSensitive = false
|
||||
isRegex = false
|
||||
}
|
||||
)
|
||||
}
|
||||
val containsCredentialId = if(credentialId == null) true
|
||||
else entry.getExtraFields().any { field ->
|
||||
field.isCredentialId()
|
||||
&& checkSearchQuery(
|
||||
stringToCheck = field.protectedValue.stringValue,
|
||||
searchParameters = SearchParameters().apply {
|
||||
searchQuery = credentialId
|
||||
caseSensitive = false
|
||||
isRegex = false
|
||||
}
|
||||
)
|
||||
}
|
||||
return containsRelyingParty && containsCredentialId
|
||||
}
|
||||
if (searchParameters.searchInNotes) {
|
||||
if (checkSearchQuery(entry.notes, searchParameters))
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.os.Parcelable
|
||||
*/
|
||||
class SearchParameters() : Parcelable{
|
||||
var searchQuery: String = ""
|
||||
// Add an optional string to search with the main search query
|
||||
var searchOption: String? = null
|
||||
var allowEmptyQuery = true
|
||||
var caseSensitive = false
|
||||
var isRegex = false
|
||||
|
||||
@@ -176,6 +176,13 @@ object PasskeyEntryFields {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if the current field is a Passkey credential id
|
||||
*/
|
||||
fun Field.isCredentialId(): Boolean {
|
||||
return name == FIELD_CREDENTIAL_ID
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect if the current field is a Passkey relying party
|
||||
*/
|
||||
|
||||
@@ -35,6 +35,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
return if (webDomain == null) null else field
|
||||
}
|
||||
var relyingParty: String? = null
|
||||
var credentialId: String? = null
|
||||
var otpString: String? = null
|
||||
|
||||
constructor()
|
||||
@@ -46,6 +47,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
webDomain = toCopy?.webDomain
|
||||
webScheme = toCopy?.webScheme
|
||||
relyingParty = toCopy?.relyingParty
|
||||
credentialId = toCopy?.credentialId
|
||||
otpString = toCopy?.otpString
|
||||
}
|
||||
|
||||
@@ -61,6 +63,8 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
webScheme = if (readScheme.isNullOrEmpty()) null else readScheme
|
||||
val readRelyingParty = parcel.readString()
|
||||
relyingParty = if (readRelyingParty.isNullOrEmpty()) null else readRelyingParty
|
||||
val readCredentialId = parcel.readString()
|
||||
credentialId = if (readCredentialId.isNullOrEmpty()) null else readCredentialId
|
||||
val readOtp = parcel.readString()
|
||||
otpString = if (readOtp.isNullOrEmpty()) null else readOtp
|
||||
}
|
||||
@@ -76,6 +80,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
parcel.writeString(webDomain ?: "")
|
||||
parcel.writeString(webScheme ?: "")
|
||||
parcel.writeString(relyingParty ?: "")
|
||||
parcel.writeString(credentialId ?: "")
|
||||
parcel.writeString(otpString ?: "")
|
||||
}
|
||||
|
||||
@@ -94,6 +99,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
&& webDomain == null
|
||||
&& webScheme == null
|
||||
&& relyingParty == null
|
||||
&& credentialId == null
|
||||
&& otpString == null
|
||||
}
|
||||
|
||||
@@ -127,6 +133,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
if (webDomain != other.webDomain) return false
|
||||
if (webScheme != other.webScheme) return false
|
||||
if (relyingParty != other.relyingParty) return false
|
||||
if (credentialId != other.credentialId) return false
|
||||
if (otpString != other.otpString) return false
|
||||
|
||||
return true
|
||||
@@ -139,6 +146,7 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
result = 31 * result + (webDomain?.hashCode() ?: 0)
|
||||
result = 31 * result + (webScheme?.hashCode() ?: 0)
|
||||
result = 31 * result + (relyingParty?.hashCode() ?: 0)
|
||||
result = 31 * result + (credentialId?.hashCode() ?: 0)
|
||||
result = 31 * result + (otpString?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
@@ -147,6 +155,10 @@ class SearchInfo : ObjectNameResource, Parcelable {
|
||||
return otpString ?: webDomain ?: applicationId ?: relyingParty ?: tag ?: ""
|
||||
}
|
||||
|
||||
fun optionString(): String? {
|
||||
return if (isPasskeySearch && credentialId != null) credentialId else null
|
||||
}
|
||||
|
||||
fun toRegisterInfo(): RegisterInfo {
|
||||
return RegisterInfo(this)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user