Reputation: 1805
I am developing an login feature using username/password and biometric
authentication. My thinking usecase is:
Token
(access_token/refresh_token).And I am very concern at 2 points:
At step 4, which thing should I encrypt? Token or username/password? . If Token, it can be expired, if username/password, it seems not a good idea.
At step 5, the token will be cleared, so in step 6, after verify biometric, how can I re-login user? Will it depends on my saved data at step 3? or if user logout, we should also disable biometric?
Thanks in advance.
Upvotes: 1
Views: 1347
Reputation: 1300
You should store session refresh token only. No need to store access tokens or, moreover, login/password.
After enabling the biometric authentication you should put encrypted refresh token and encryption iv somewhere (in shared preferences or in db for example) and store encryption key in device's secure store.
On step 5 user shouldn't logout. As logging out means you will close the session and won't be able to reuse it, forcing a user to enter login and password again.
When a user starts the app, you will get the key and decode Refresh Token. Then you will use it to get new Access Token.
For all this to work properly, you should have a long life-time for refresh tokens and short for access tokens.
Upvotes: 0