okta / okta-storage-swift

Secure storage library
https://github.com/okta/okta-storage-swift
Other
8 stars 8 forks source link

Extending API by implementing getStoredKeysMatching(prefix:biometricP… #27

Closed AntonVoitsekhivskyi-okta closed 3 years ago

AntonVoitsekhivskyi-okta commented 3 years ago

…rompt:accessGroup:) function

Problem Analysis (Technical)

Currently, there are no possibility to access keychain by some key prefix and not the exact key.

Solution (Technical)

Extending API by requesting Keychain items attributes and then filter keys by prefix: getStoredKeysMatching(prefix:biometricPrompt:accessGroup:)

The function replicates hasPrefix() behaviour for String from Swift's Foundation. If this needs to be extended to accept some regex-backed search, please let me know. "Has prefix" approach is initially chosen from a performance perspective

Affected Components

Steps to reproduce: N/A

Actual result:

Expected result:

Tests

Added testSetAndMultipleGetByPrefix()

AntonVoitsekhivskyi-okta commented 3 years ago

@IldarAbdullin-okta @oleggnidets-okta @MikeMondragon-okta Haven't found how to tag you as reviewers guys from Fork-based PR, so mentioning you here for review, thanks

mikenachbaur-okta commented 3 years ago

Instead of searching for keys by prefix, have you considered making an API that could return the list of keys instead? That way you're not limited to filtering by prefix, instead you could use the existing APIs to get the stored values, once you have the keys you're interested in.

AntonVoitsekhivskyi-okta commented 3 years ago

@mikenachbaur-okta Returning the whole list of keys sounds good to me. Refactored getStoredKeysMatching() -> getStoredKeys() to return an array of stored keys and let client decide, which way to traverse / filter through the result.