I have kind of a unique usecase:
- Phones that are used to connect to the app might be shared
- Connections are very unstable (sometimes no connection for half a day)
- Data should be accessible through the interface only by an authenticated user
- The data should be accessible after the first login for each user
- Users are not really tech sure
PWAs use JavaScript and therefore do have a restricted possibilities for encryption.
My current setup is
- angular app with pwa possibilities
- PouchDB with remote CouchDB sync for data
I feel like it is not a good idea to store user credentials on the device even if they are encrypted, especially when using JavaScript.
Is this even possible to achieve? And what kind of flow would you recommend. I thought about creating a unique (short, four letter) token that the user has to remember when logging out. It is stored encrypted together with the username. This token in combination with the username can then be used to relogin as long the application is offline. As soon as the app is online again the user is asked to login with its real credentials. If this succeeds the token is deleted and a new one is created (and shown to the user) when the user logs out.