Django and Next.js shared Authentication - django

I am building a new front end with Next.js for my Django App. I have been splitting the development to keep all the dashboard running on Django, while the rest runs on Next.js.
Next.js is running on <domain.com>. The existing Django will be running on dashboard.<domain>.com.
I have setup all the REST Authentication for Next.js and is working fine.
Now what I'm trying to achieve is when you login from <domain>.com you don't need to authenticate to the dashboard and reuse the same Authentication.
Django seems to have some cookie Authentication and I'm using JWT for Next.js.
What would be my options to solve this dilemma?

Related

User authentication with Django and NextJS

I am building a project that uses Django Rest Framework as the backend and NextJS serves React frontend. How can I integrate user authentication using these two technologies?
In the future we might build a mobile app as well, so we need the backend to be consistent.
Thank you for your time.
I would suggest using the JWT tokens for authentication. You will not face any problem if you change your frontend. To get an idea on implementation, check this answer - https://stackoverflow.com/a/62112041/12840065

Laravel OAuth2 authentication for Django Site

I am building a Django application and I need to connect to an existing external Laravel site to authenticate users. Basically to have two different platforms, but users only have one set of credentials. Also - users should be able to sign up on the Django, and their user is created in the Laravel DB.
The Laravel site has Laravel Passport (OAuth2 based) installed because it uses it for a Flutter app.
I know that REMOTE_USER is "the Django way" of achieving external auth but, I don't know where to go from there. If it makes a difference, the Django app will be a full REST application using DRF because its frontend will be ReactJS.
Can anyone explain how to achieve external auth with Django, particularly when the authentication server is OAuth2 based? Or better yet, how it can work with Laravel Passport in particular.
Thanks

Authentication in django for both web and mobile

I have django website running with django-allauth authentication.
Now, I am planning to build a mobile app using already existing django as a backend.
If there is a way I can continue using django-allauth as authentication for mobile app ?
What is the standard way to implement authentication in django for both web and mobile ?
You could try django rest framework to build a restful api that your mobile application makes use of. It comes with support for OAuth.

Web Development - Should social login be performed on frontend or handled on the backend of and application?

I am building a social login based application using Django on the backend and I want to know whether it is a good practice to do Social Auth(facebook, google, github, twitter etc.) on the front end or the backend of an application?
For example, If I want to allow a user to signup using their facebook account, is it a good idea to handle that using JavaScript on the front end or using Django on the backend(e.g, using something like social_auth_app_django)?
Both sides =) The authToken you store should placed in your backend while the session interaction could be done with the frontend.
If you are a beginner ,My recommendation is to go with Django Social Auth.
Django Social Auth is an easy way to setup social authentication/authorization mechanism for Django projects.
docs : http://django-social-auth.readthedocs.io
github :https://github.com/omab/django-social-auth
Installation:
pip install django-social-auth

using django authentication and session on remote front end

I have a website that front-end and back-end are on different servers. Front-end part is on angular 2 and webpack and gets dynamic data from back-end using ajax.
Back-end uses django framework for database management and ORM.
Is it possible to use django authentication and session management and Auth.User model for the front-end in back-end part?