Package: django-next-auth-adapter
Django Next Auth AdapterDjango Next Auth Adapter is a Django package designed to handle server-side requests from the "next-auth-http-adapter" JavaScript package. This package is intended for use with Next.js and NextAuth.js to seamlessly integrate custom backend functionality into the NextAuth.js authentication flow by facilitating HTTP communication between the frontend and backend.Pre-requisitesUser Modeladd the following to your user modelclassUser(AbstractBaseUser):# ...email_verified=models.DateTimeField(blank=True,null=True)# ...EMAIL_FIELD="email"USERNAME_FIELD='email'REQUIRED_FIELDS=['username']# ...InstallationYou can install the package via pip:pipinstalldjango-next-auth-adapterConfigurationTo configure the Django Next Auth Adapter, you need to define certain settings in your Django project's settings module (settings.py).Includedjango_next_auth_adapterin yourINSTALLED_APPS:# settings.pyINSTALLED_APPS=[# Your other installed apps"django_next_auth_adapter",]For custom configuration, add the following settings to yoursettings.pyfile:# settings.pyDJANGO_NEXT_AUTH_ADAPTER={# optional: specify the permission classes applied to views within the package. Customize these classes as needed to control access to your views. Do not specify this parameter if you want to use the default permission classes."PERMISSION_CLASSES":[# Add your permission classes here],# optional: specify the token used for authenticating requests from the next-auth server. If not provided, authentication will be bypassed."REMOTE_AUTH_TOKEN":"your-remote-auth-token",}Available SettingsDJANGO_NEXT_AUTH_ADAPTER (dictionary):The main configuration dictionary for the package.PERMISSION_CLASSES (list):This is a list of permission classes applied to views within the package. Customize these classes as needed to control access to your views.REMOTE_AUTH_TOKEN (string, optional):The token used by the default permission class for authenticating requests from the next-auth server. If not provided, authentication will be bypassed.UsageTo use the Django Next Auth Adapter, import it as follows:fromdjango_next_auth_adapterimportDjangoNextAuthAdapterYou can then use the imported classes and functions to handle authentication and authorization as needed within your Django views.Configuration inurls.pyTo include the package's URLs in your Django project, follow these steps:Open your project's baseurls.pyfile.Import the package's views and include them in your URL patterns.# urls.pyfromdjango.urlsimportpath,includefromdjango_next_auth_adapter.viewsimportYourViewName1,YourViewName2# Import your views hereurlpatterns=[# Your other URL patternspath('next-auth/',include('django_next_auth_adapter.urls')),# Include the package's URLs here]SignalsThe package provides the following signals that you can use to customize the authentication and authorization process:user_created:Sent when a new user is created. The signal sends the following arguments:sender:The serializer class.user:The user instance.validated_data:The validated data used to create the user.image:The image url of the user.name:The name of the user.user_updated:Sent when a user is updated. The signal sends the following arguments:sender:The serializer class.user:The user instance.validated_data:The validated data used to create the user.image:The image url of the user.name:The name of the user.LinksGitHub Repositorynext-auth-http-adapterLicenseThis project is open source and is licensed under the MIT License.