Metadata-Version: 2.1
Name: django-auth-app
Version: 0.3.2
Summary: A Django authentication boilerplate with OTP and role-based access control
Home-page: https://github.com/sajan69/django-auth-boilerplate
Author: Sajan Adhikari
Author-email: sajana46@gmail.com
License: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: django>=3.0
Requires-Dist: djangorestframework
Requires-Dist: drf-yasg
Requires-Dist: setuptools
Requires-Dist: PyJWT
Requires-Dist: requests



# django-auth-app

A Django authentication boilerplate with OTP and role-based access control. This package provides a robust and reusable authentication system, including basic registration, login/logout, password management, OTP setup and email verification.

## Features

- **Basic Authentication**: Registration, login, logout, password change.
- **OTP Verification**: For registration and password reset.
- **Email Verification**: Through SMTP.
- **Role-Based Access Control (RBAC)**: Differentiated roles for custom and social registrations.
- **Swagger Documentation**: API documentation.
- **JWT Token Authentication**: For API access.

## Installation

1. **Install the package**:
   
   ```bash
   pip install django-auth-app
   ```

2. **Add the app to your Django project**:

   In your `settings.py`, add `auth_app` to your `INSTALLED_APPS`:

   ```python
   INSTALLED_APPS = [
       # Other installed apps
       'auth_app',
       'rest_framework',
       'drf_yasg',
       
   ]
   ```
   **Set the custom user model:**

  This package provides a custom user model. You should update the `AUTH_USER_MODEL` setting:

  ```python
  AUTH_USER_MODEL = 'auth_app.CustomUser'
  ```

3. **Configure SMTP for email sending**:

   Add your SMTP settings to `settings.py`:

   ```python
   EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
   EMAIL_HOST = 'smtp.example.com'
   EMAIL_PORT = 587
   EMAIL_USE_TLS = True
   EMAIL_HOST_USER = 'your_email@example.com'
   EMAIL_HOST_PASSWORD = 'your_email_password'
   ```

4. **Set up JWT authentication**:

   Add the following to `settings.py`:

   ```python
   REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ],
    
}
   ```

5. **Include the URL configurations**:

   Add the following to your project's `urls.py`:

   ```python
from drf_yasg.views import get_schema_view
from drf_yasg import openapi
from rest_framework import permissions


schema_view = get_schema_view(
    openapi.Info(
        title="Authentication API",
        default_version='v1',
        description="API documentation for authentication features including registration, OTP verification, and password reset.",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="contact@api.local"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
    #Other urls
    path('auth/', include('auth_app.urls')),  # Custom authentication URLs
    path('docs/', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    path('redoc/', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    #Other urls
]

   ```

8. **Run migrations**:

   ```bash
   python manage.py makemigrations
   python manage.py migrate
   ```

## Usage

### Web Views

- **Registration**: `/register/`
- **Login**: `/login/`
- **Logout**: `/logout/`
- **Password Change**: `/password-change/`
- **Password Reset**: `/password-reset/`
- **OTP Verification**: `/otp-verify/`

### API Endpoints

- **Register**: `api/register/`
- **Login**: `api/login/`
- **OTP Verify**: `api/otp-verify/`
- **Password Change**: `api/password-change/`
- **Password Reset**: `api/password-reset/`

### Swagger Documentation

- **Swagger UI**: `/docs/`

## Development

To contribute to the development of `django-auth-app`, clone the repository and install the dependencies:

```bash
git clone https://github.com/sajan69/django-auth-boilerplate.git
cd django-auth-boilerplate
pip install -r requirements.txt
```

## Testing

To run tests, use:

```bash
pytest
```

## License

MIT License. See the [LICENSE](https://github.com/sajan69/django-auth-boilerplate/blob/main/LICENSE) file for details.

## Author

Sajan Adhikari  
[sajana46@gmail.com](mailto:sajana46@gmail.com)

---
