2

I'm looking for a way to register and authenticate custom users accross mutiple databases using Django and postgreSQL.

The application will be cross countries (still brainstorming). Regarding the different laws we need to store the users details inside their own country. For exemple, US users must have data stored in the US, Canadians users stored in Canada and Europeans users stored in Europe.

The problem is that Django (1.11) doesn’t currently provide any support for foreign key or many-to-many relationships spanning multiple databases.

So I came up with 2 options at the moment but I can't see the perfect one. I'm asking if you would have a better solution.

Then integrate Django with a legacy database

Pros: Supports foreign database relationships

Cons: Manual migration, manual integration, custom scripts.

Pros: Easier Django integration

Cons: Risk of data corruption. I would avoid it!!

Thanks

Django: 1.11

PostgreSQL 9.6

Python 3

CMdev
  • 21
  • 1

1 Answers1

0

I can think of two other options:

  1. Make authentication external to your application. Django and RESTful systems are inherently modular. Your system does not need to serve application content and authentication from the same Django instance nor do you even need to use Django to authenticate. In fact, given your requirements, I would be inclined to offload authentication to a reliable, third-party service such as Google's service. By using a third party service, you outsource compliance/regulatory concerns that might not be relevant to your early development. For the instance of Google, there are lots of discussions. One on SO is at How to sign in with the Google+ API using Django? There are also Facebook and other authentication options.

  2. Customize the authentication provided by Django. I would start at https://docs.djangoproject.com/en/1.11/topics/auth/customizing/

After posting, it occurs to me that you might be concerned about two different problems:

  • (a) storing authentication, personal data in the correct country
  • (b) storing all user data in the user's country

The answer really applies to a. If you need to store all user data in the user's country, then outsourcing authentication is not a sufficient solution.

Community
  • 1
  • 1
sage
  • 4,863
  • 2
  • 44
  • 47
  • Thanks @sage. Yes all the user's tables must be stored in the user's country. That's the tricky part. – CMdev Apr 18 '17 at 17:36