How to implement an effective biometric authentication with androidx.biometric and Jetpack Compose with a sample app as a reference.
When the biometric authentication flow is triggered, the user will be prompted to authenticate using their enrolled biometric data. Upon successful
Biometric Authentication
After a valid username-password login (in the sample app, every login with not-null username and password is a valid login :) ) what we want is to: ask the user to confirm with a biometric authentication its identity and, contextually, have the chance to fetch and store a token encrypted with a key that requires always a user authentication to beco.
Connect UI Layer with Data Layer
Finally we’ll connect our ui layer with our data layer.
We can omit the management of the form and only have a zoom-in on what we need to do to connect our data layer with our ui layer (via viewModel obviously :) ).
We’ll ignore all the error management aspects not strictly related to Biometric Api In our LoginViewModel we have to inject UserReposi.
Cryptographic Layer and User Authentication
What is CryptoObject.
This entity is a wrapper class for the cryptographic operations supported by BiometricPrompt (Signature, Mac and Cipher) BiometricPrompt could work without an instance of CryptoObject as input.
However, in this situation, on the succeeded callback, CryptoObject is always null so our authentication works but without involving c.
Data Layer
Via Hilt, we can define that our CryptoEngine will be a singleton instance injected in our BiometricRepository.
We have already explored the getBiometricInfo() before: it’s an api the gives us a snapshot of the biometric state.
When we need to encrypt or decrypt our token, we need to create a CryptoObject with a specific purpose (encrypt or decrypt.
How do I integrate cryptography into my biometric authentication workflow?
Prompt appears when user clicks "Log in".
To further protect sensitive information within your app, you can incorporate cryptography into your biometric authentication workflow using an instance of CryptoObject .
The framework supports the following cryptographic objects:
Signature Cipher and Mac. How to load image from URL in jetpack compose?
To load image from url in Jetpack compose we will use Glide image library similar to normal android application Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs.
Glide includes ,a flexible API that allows developers to plug in to almost any network stack.
What is Jetpack compose?
Now, it’s time to say hello to Jetpack Compose! Jetpack Compose is Android’s modern toolkit for building native UI.
When you learned about how difficult building a UI in Android with the original Android UI toolkit is, you started with the basic, familiar building blocks, View and ViewGroup.
What is the border modifier in jetpack compose?
Corrected Modifier.border for Jetpack Compose.
It adjusts inner rounded corner rectangle instead of using the same radius as outer rounded corner rectangle. · GitHub Instantly share code, notes, and snippets.
Corrected Modifier.border for Jetpack Compose.