I'm working on a web project that will connect to a database. For that, I will have to store the login/password of that database user in clear (encrypted in a symmetrical way) in order to be able to reconnect for every action (like creating table, adding entries, etc) without having to ask for those credentials everytime.
I'm aware that storing the password in clear is way too insecure and out of my possibilities.
Here's what I thought, could you tell me if it would be correct or/and if there is a better possibility? thanks :)
The application will be splitted in two independant parts : the frontend and the backend.
When the user log in via the frontend, the login and password are sent in clear (I will recommand the use of HTTPS). The backend will try to connect to the database, if it's successful, it will encrypt the login and password using Blowfish, and return them to the frontend.
For any subsequent requests, the frontend will have to send the encrypted login/password, without ever knowing the clear one, just the encrypted one.
If someone get access to the data of this user (XSS for example), he only will be able to access the encrypted credentials, not the clear one.
If an attacker can do a MITM, only the initial log in is risky, all the next requests will be with the encrypted credentials.
I thought about using cookies/session, but it's the same : values are stored in clear or base64 encoded. Not really secure!
The idea of Blowfish come from how PhpMyAdmin use it (aka, the same). Moreover, even on PhpMyAdmin, the login part is also sent in clear.
Do you think my implementation is correct, or do you have something better to suggest? I'd really like to do something as secure as possible. So far, only the login part bothers me :/
Thanks for your ideas.
EDIT:
Apparently, my question is not clear enough, I'm gonna try to be more explicit :
I want to build an alternative to PhpMyAdmin. PhpMyAdmin is a middleware that connect to a MySQL server by giving the login/password of any user in that database. The credentials asked in the web form are the one used for the MySQL database.
So, during the whole session after the user successfully logged in, PhpMyAdmin store the login/password in the session by encrypting the password using Blowfish.
This CAN NOT be avoided, because every time the user make a request (like creating a table, inserting data, updating or deleting data), PhpMyAdmin NEED to reconnect to that database using the credentials given at login, and then do the action the user requested.
It's then not possible for PhpMyAdmin to only store a hash of the credentials because it won't be able to reconnect to the database during subsequent requests made by that same user.
I'm aware storing password that can be retrieved in clear is not a good solution at all, and that is the reason of this question : not telling me that hashing is better, because it's absolutely useless in my case, but to know if there is a better alternative than symmetrical encryption + HTTPS for keeping a password that is needed for every actions the user make.