incuna / django-pgcrypto-fields

Transparent field level encryption for Django using the pgcrypto postgresql extension.
BSD 2-Clause "Simplified" License
229 stars 49 forks source link

Sharing encrypted DB in multiple Django projects #559

Closed dizzydes closed 8 months ago

dizzydes commented 1 year ago

Are there any potential issues here? Is it just a case of having the same secret key across the projects?

some1ataplace commented 1 year ago

Technically, it is possible to share an encrypted database across multiple Django projects if the databases are compatible (i.e. use the same database engine and schema). However, it's generally not considered a good practice due to several reasons:

  1. Security: Sharing an encrypted database increases the risk of a security breach since the same encryption key is used across multiple projects. If the encryption key is compromised in one project, it could be used to access the database in the other projects.

  2. Complexity: Sharing an encrypted database adds complexity to the database configuration, especially if the projects require different encryption algorithms or key sizes.

  3. Management: Managing a shared encrypted database can be difficult, especially if some projects need to be upgraded or modified, which could break the compatibility of the database.

If you really need to share data between multiple projects, a better approach would be to use an API to expose the data from one project and allow other projects to access it through the API.

In terms of sharing the same secret key across multiple projects, it's generally not advisable since the secret key is used for encrypting sensitive information and authenticating users. If the secret key is compromised in one project, it could be used to gain access to the other projects.