The project includes the creation of a RESTful API user model using Django Rest Framework (DRF), integration of authentication and authorization, using Auth0 for authentication.
- The user's model. User registration, login, user profile acquisition, user profile update and account deletion.
- Secure password hashing and storage. Secure password hashing and storage using the Django - Argon hashing algorithm.
- Validation and Error handling. Appropriate validation and error handling methods for endpoints are implemented.
- Custom User model and Authentication. Custom user model that includes email as a unique identifier.
- Python 3.7
- Django 3.2.20
- Django Rest Framework 3.14.0
- djangorestframework-simplejwt 4.8.0
- djoser 2.1.0
- drf-yasg 1.21.7
- argon2-cffi 23.1.0
- http://127.0.0.1:8000/
- http://127.0.0.1:8000/redoc/ - project documentation
- http://127.0.0.1:8000/admin/ - admin page
Clone the repository and navigate to it in the command line:
git clone https://github.com/DmitryOstrovskiy/LongevityInTime_Test_Tasks && cd LongevityInTime_Test_Tasks
Install the virtual environment, activate it and install dependencies:
python -m venv venv && Windows: ```source venv\scripts\activate```; Linux/Mac: ```sorce venv/bin/activate``` && pip install -r requirements.txt
Perform migrations:
python manage.py migrate
Create a superuser:
python manage.py createsuperuser
Start the server:
python manage.py runserver
POST: http://127.0.0.1:8000/api/auth/users/
Request example:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"username": "IvanIvanov",
"password": "UserIvan1",
"email": "[email protected]"
}
Response example:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"username": "IvanIvanov",
"email": "[email protected]",
"id": 2
}
POST: http://127.0.0.1:8000/api/auth/jwt/create/
Request example:
{
"email": "[email protected]",
"password": "UserIvan1"
}
Response example:
{
"refresh": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoicmVmcmVzaCIsImV4cCI6MTY5MzkyMjE5NCwianRpIjoiOTg0NzFiYTg1MDgyNDIzN2I1NDZjMTYyZTczNzM2MzUiLCJ1c2VyX2lkIjoyfQ.AA7j0s3gdmfPLamYy9FxomsN00zXfs73-8RGkWFWs2E",
"access": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjkzOTIyMTk0LCJqdGkiOiJhZTNiMDM0ZjRmMGQ0MmU5OWJhMGVjNTRiODRlMDQ5OCIsInVzZXJfaWQiOjJ9.Rvcm8ZfiRUGi0XsBglMXLzhQn5jV2L40V53X-RZHQbs"
}
GET: http://127.0.0.1:8000/api/auth/users/2/ - In the Authorization tab, you need to pass an access token Response example:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"username": "IvanIvanov",
"password": "pbkdf2_sha256$260000$Zn7FJL7NbWZve3dbPbqMGJ$/1EmKlUMQ0SfGGClHnxjrSH4xH8PBekFuJAmBjuO048=",
"id": 2,
"email": "[email protected]"
}
PUT: http://127.0.0.1:8000/api/auth/users/2/ - In the Authorization tab, you need to pass an access token Request example:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"username": "SuperIvan",
"password": "UserIvan1234",
"email": "[email protected]"
}
Response example:
{
"first_name": "Ivan",
"last_name": "Ivanov",
"username": "SuperIvan",
"password": "UserIvan1234",
"id": 2,
"email": "[email protected]"
}
DELETE: http://127.0.0.1:8000/api/auth/users/2/ - In the Authorization tab, you need to pass an access token Request example:
{
"current_password": "UserIvan1234"
}