Setup
To set up the base library, follow the following steps.
- 
Create a api.pyfile in your app directory next to thesettings.pyandurls.pyfiles. This file will hold your Ninja Extra API instance.
- 
Add the following lines of code to your api.pyapi.pyfrom ninja_extra import NinjaExtraAPI
 from dj_ninja_auth.controller import NinjaAuthDefaultController
 api = NinjaExtraAPI()
 api.register_controllers(NinjaAuthDefaultController)
- 
Add the following lines to your urls.pyfileurls.pyfrom .api import api
 urlpatterns = [
 path("admin/", admin.site.urls),
 path("", api.urls)
 ]
- 
Add the following to your settings.pysettings.pyINSTALLED_APPS = [
 ...
 "ninja_extra",
 "dj_ninja_auth",
 ...
 ]
 AUTH_PASSWORD_RESET_URL = "http://localhost:8000/<YOUR_PASSWORD_RESET_FRONTEND_URL>/"
This will give you 5 basic endpoints that are not secured and can be called by anyone. The endpoints are:
- /auth/login
- /auth/logout
- /auth/password/reset/request
- /auth/password/reset/confirm
- /auth/password/change
Viola! You can start authenticating your users. To view and test the endpoints, you can visit http://localhost:8000/docs.
The NinjaAuthDefaultController sends back the data associated with the authenticated user but cannot keep track of a user's state.
This means that beyond changing passwords and getting the user's data, the NinjaAuthDefaultController is functionally useless without at least session authentication using cookies.