User-Auth is user authentication backend built using Django Rest Framework and djangorestframework-simplejwt. Please refer to the documentation to learn more about the libraries. The project also overrides django default user authentication to add more features.
-
Recommended that you create a virtualenv using your virtualenv library of choice e.g. venv, virtualenv, pipenv e.t.c.
-
Navigate to your virtualenv
cd virtual-en
and activate your environment. -
Clone the project to the created virtual environment
git clone https://github.com/edewajosh/User-Auth.git
-
Navigate to your project and run
pip install -r requirements.txt
to install project libraries -
You can launch the project locally by running
python manage.py runserver
The application has a single endpoint to enable perform POST, PUT, GET, PATCH, DELETE for User model. Since the application uses drf-simple-jwt there are three(3) other endpoints for obtaining, verifying, and refreshing token.
To list all the existing endpoints click http://localhost:8000/api/
.
Below are the requests to executing the User endpoint http://localhost:8000/api/users/
simple-jwt Token
- POST: Obtaining token :
127.0.0.1:8000/api/token/
{
"email": "jane.doe@example.com",
"password": "password@123"
}
- POST: Verify token :
- POST: Refresh token :
127.0.0.1:8000/api/token/
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTYxMDQzNzgyOSwianRpIjoiNjZjZTM3NThhMDQ3NDcxMzlhOTUxMGU0ODVhNGNlOTkiLCJ1c2VyX2lkIjo0fQ.pziGk0yeY2CMCF71-jkOzcJJQQ2NB5ScDb5J8Av0Tpk"
}
User endpoint
- POST (Authentication Token) payload
{
"first_name": "Kyle",
"last_name": "Smith",
"email": "kyle.smith@example.com",
"password": "password@123",
"confirm_password": "password@123"
}
- GET (Authentication Token) Response
[
{
"first_name": "Jane",
"last_name": "Doe",
"email": "jane.doe@example.com",
"is_admin": true,
"is_active": true,
"is_staff": true
},
{
"first_name": "John",
"last_name": "Smith",
"email": "John.Smith@example.com",
"is_admin": true,
"is_active": true,
"is_staff": true
},
{
"first_name": "Lucas",
"last_name": "Estrada",
"email": "lucas.estrada@example.com",
"is_admin": false,
"is_active": false,
"is_staff": false
},
{
"first_name": "Alex",
"last_name": "Alexander",
"email": "alex.alexander@example.com",
"is_admin": false,
"is_active": false,
"is_staff": false
},
{
"first_name": "Allan",
"last_name": "Walker",
"email": "Alan.Walker12@example.com",
"is_admin": false,
"is_active": false,
"is_staff": false
},
{
"first_name": "alex12",
"last_name": "alexander",
"email": "alex12.alexander@example.com",
"is_admin": false,
"is_active": false,
"is_staff": false
}
]
- PUT payload
{
"first_name": "Kyle",
"last_name": "Smith",
"email": "kyle.smith@example.com",
"password": "password@123",
"confirm_password": "password@123"
}
- PATCH
- DELETE