To maintain uniformity in how passwords are stored and handled in our database, it might be helpful to enforce encryption for all user entries. We need to ensure that user passwords are bcrypt encrypted when stored in our PostgreSQL database. Currently, passwords created through pgAdmin are not encrypted, posing a security risk. This issue will cover the implementation of password encryption within the application logic to secure user passwords and to give us more control over the encryption process. This update will help improve the security of the user data.
Approach 1
I think the application logic should have more knowledge on a user created manually on the pgadmin or those created in the application's logic. This way, we can create a database trigger that run before insert is called only for such users. This may require the addition of FROM_ADMIN (or similar name) default to true in the schema.prisma file.
Task
[ ] update the schema to acknowledge admin created users
[ ] create a trigger query that encrypt password for pg-admin created users using bcrypt
[ ] Go to the pgadmin site and create two users with plain text password and {isVerified: true} {isVerified: false} respectively, save them and see if the passwords are encrypted
To maintain uniformity in how passwords are stored and handled in our database, it might be helpful to enforce encryption for all user entries. We need to ensure that user passwords are bcrypt encrypted when stored in our PostgreSQL database. Currently, passwords created through pgAdmin are not encrypted, posing a security risk. This issue will cover the implementation of password encryption within the application logic to secure user passwords and to give us more control over the encryption process. This update will help improve the security of the user data.
Approach 1 I think the application logic should have more knowledge on a user created manually on the pgadmin or those created in the application's logic. This way, we can create a database trigger that run before
insert
is called only for such users. This may require the addition of FROM_ADMIN (or similar name) default to true in the schema.prisma file.Task