-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: crash in encryption library #638
Conversation
Remove the encryption done by the keystore library, and instead migrate to just store the tokens in shared preferences. They should be safe without being encrypted as they are just some tokens, and require root to access anyway. BREAKING CHANGE: Old shared preference values will be deprecated and no longer be valid
Higher Android SDK versions can use the new androidx crypto library, add using this encrypted preferences for these Android versions and fallback to unencrypted preferences when we are on a lower sdk version.
Change the test file for the AuthProvider to now be for the LocalAuthV1 class
Code Refactoring
Tests
StylesContributorsCommit-Lint commandsYou can trigger Commit-Lint actions by commenting on this PR:
|
libraries/datasource/auth/src/main/java/com/chesire/nekome/datasource/auth/local/LocalAuthV2.kt
Show resolved
Hide resolved
libraries/datasource/auth/src/main/java/com/chesire/nekome/datasource/auth/local/LocalAuthV2.kt
Show resolved
Hide resolved
libraries/datasource/auth/src/main/java/com/chesire/nekome/datasource/auth/local/LocalAuthV2.kt
Outdated
Show resolved
Hide resolved
Generated by 🚫 Danger |
libraries/datasource/auth/src/main/java/com/chesire/nekome/datasource/auth/local/LocalAuthV2.kt
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #638 +/- ##
============================================
- Coverage 70.22% 69.79% -0.43%
- Complexity 434 454 +20
============================================
Files 106 110 +4
Lines 1639 1725 +86
Branches 139 145 +6
============================================
+ Hits 1151 1204 +53
- Misses 445 477 +32
- Partials 43 44 +1
Continue to review full report at Codecov.
|
libraries/datasource/auth/src/main/java/com/chesire/nekome/datasource/auth/local/LocalAuthV2.kt
Outdated
Show resolved
Hide resolved
Only perform the initialization of the unencrypted preferences if the encrypted preferences is empty. If this is empty then its likely the user has just updated their SDK version and we can then migrate. This stops it initializing two shared prefs every time.
Fix issues with missing kdoc, suppress some unneeded warnings, etc
} else { | ||
"" | ||
} | ||
} catch (ex: Exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The caught exception is swallowed. The original exception could be lost. |
Do some refactoring to make it possible to test the class as well.
Remove unused import
Crash is sometimes occurring when using the encryption library due to something wrong with the KeyStore in Android.
Done some debugging and it seemed to always be causing an issue while a value was in the preferences, so move away from using the library and instead use the new encrypted shared preferences when possible.
Once this has been merged for a few weeks the encryption library can be tore out completely.