I have two types of Django servers. One is a central server that contains a master database. There's only one of these.
Then there's an arbitrary number of client servers that contain their own databases. These client databases act as a cache for the master database.
This is used for users. I a user tries to log in on client server 1, that server looks for the user in its database. If it's not there, it goes out to the central server and asks that server if the user exists in the master database. If so, the central server returns the users info so that the client server can store/cache it in its own database and then log the user in. Each successive time that user tries to log in, the user is found in the client database and it no longer has to go out to the central server.
The central server returns the users information as JSON like so:
{
"username": "joe.bag.o.doughnuts",
"id": 143,
"password": "fksdfjfldskjf",
}
My issue here is the password. when I put the value in there as just user.password
, it uses the encrypted version of that password. This is good because I don't want the plain text password out there in http connections for security reasons. However, how do I store the encrypted password correctly when creating a copy of the user on the client server? If I set password to the encrypted text (User.objects.create(username=<retrieved_username>, password=<retrieved_password_which_is_already_encrypted>)
), it will treat it as a plain text password and will then encrypt it... even though it's already encrypted so it's encrypting the encryption, not the actual password.