1

So I am developing a Java app which is going to be free and would preferably not require a sign up process. I cannot seem to think of an idea to store the log in details safely.

I have thought of salting and hashing the password but it means that I won't be able to recover the password to use it for the database. I have also thought of using encryption but that would mean that I would be storing the encryption key in the app which also doesn't seem safe.

What are the best practices for this issue? The data doesn't consist of any personal data but it would be nice to know how to protect the database.

1

Since I assume your database will be accessible to the Internet, definitely use an encrypted connection between your app and the database. MySQL has documentation on this here.

One approach is to wrap the database with a web service. This lets you store the database password in the web service, instead of the app. This also gives you more power in deciding what queries are run against the database.

Another approach is to dynamically generate a user in the database for the app when the app is installed. This will allow you to make sure that the user's database credentials are unique, so that any action done against the database can be traced to a single installation of the app.

However, this leads me to a bit of a tangent:

Consider role-based access control for your app.

If your app only reads data from the database, and if you are concerned with the integrity of data in your database, consider creating two user roles in your database. One user role will be able to create, modify, or delete data: this user is for your use as administrator of the app. The other user role can only read data: this is the role of user your app will use to log into the database.

MySQL has capabilities to perform this sort of role-based access control, albeit awkwardly - check out the MySQL documentation to learn more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.