On Nov 11, 2017 10:55 PM, "Asif Saifuddin" <auv...@gmail.com> wrote:
Hi, I have and existing live project running on rails. I have to expose the API's using django for now. I have generated models and edited them to create django model and mapping and exposed some API locally. I have one issue which is confusing my mind. That is how would I use the existing users/authors etc from DB to django User management system? Any suggestion would be appreciated. You would likely have to recreate the users on the Django side based on a data dump from Rails. That part should be easy to do. If Rails does not use a compatible password hash algorithm, then you probably can't copy the password haha over. If that's the case, generate random passwords (or set them as unusable, which I think Django supports) and force password resets. If you want to authenticate against the existing Rails database, you'll need to write a custom Django authentication back-end that knows how to retrieve the Rails credentials and authenticate the user. This could include an API call from Django to Rails to log in to the Rails application. Once the user successfully logs in to the Rails app, I would recommend creating the user locally in Django automatically (using the password that just worked against Rails). If you have the built-in auth system listed before your custom back-end, then the next time the user logs in, they'll authenticate directly against Django, effectively migrating the user transparently, and Django does not need to talk to Rails again for that user. Note that the user will now unknowingly have two sets of credentials, and changing the password on one system will not sync with the other. You can also potentially use Django to dip in to the Rails database, but that would be much more messy. SSO is also an option, although there's a fair amount of infrastructure needed for that. The API call is probably the easiest way to move the users over. Users who don't migrate themselves by logging in can later be manually migrated by creating users and forcing password resets, like I mentioned. In any event, you'll probably be writing a custom authentication back-end. https://docs.djangoproject.com/en/1.11/topics/auth/customizing/ -James -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWWzNu4RXqxuVJR%2BnXZHxXPLrxZAhV_iOh-q%3Dc3JDPt0w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.