Skip to main content

Micro framework for Django

Project description

Django Micro framework

Micro framework for Django REST Framework


Requirements

  • Python (3.6)
  • Django (2.0, 2.1, 2.2, 3.0)
  • Django REST Framework (3.8, 3.9, 3.10)

Installation

Micro Framework can be installed with pip

pip install djangomicroframework

Then, go to your django project. In settings.py:

REST_FRAMEWORK = {
    'DEFAULT_PARSER_CLASSES': (
        'rest_framework.parsers.JSONParser',
        'rest_framework.parsers.FormParser',
        'rest_framework.parsers.MultiPartParser'
    ),
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'micro_framework.jwt_auth.authentication.JWTTokenUserAuthentication',
    ]
}

from datetime import timedelta
MICRO_FRAMEWORK = {
    'SERVICE_NAME': 'Default',
    'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5),
    'REFRESH_TOKEN_LIFETIME': timedelta(days=1),
    'ROTATE_REFRESH_TOKENS': False,
    'BLACKLIST_AFTER_ROTATION': True,

    'ALGORITHM': 'HS256',
    'SIGNING_KEY': settings.SECRET_KEY,
    'VERIFYING_KEY': None,
    'AUDIENCE': None,
    'ISSUER': None,

    'AUTH_HEADER_TYPES': ('Bearer',),
    'USER_ID_FIELD': 'id',
    'USER_ID_CLAIM': 'user_id',

    'AUTH_TOKEN_CLASSES': ('micro_framework.jwt_auth.tokens.AccessToken',),
    'TOKEN_TYPE_CLAIM': 'token_type',

    'JTI_CLAIM': 'jti',

    # Custom payload Token
    'ADD_USER_IP_CLAIM': False,
    'USER_IP_CLAIM': 'user_ip',

    'ADD_USER_AGENT_CLAIM': False,
    'USER_AGENT_CLAIM': 'user_agent',

    'VALIDATE_SOURCE_IP': False,
    'HEADER_IP_REMOTE': ['HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR'],
    

    # Redis backend
    'REDIS_ENABLE': False,
    'REDIS_HOST': 'localhost',
    'REDIS_PORT': 6379,
    'REDIS_PASSWORD': None,
    'REDIS_DB': 0,
    'REDIS_EXPIRE_TOKEN': False,
}

Acknowledgments

This project is forked and custom from https://github.com/davesque/django-rest-framework-simplejwt

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangomicroframework-0.0.3a2.tar.gz (16.4 kB view details)

Uploaded Source

File details

Details for the file djangomicroframework-0.0.3a2.tar.gz.

File metadata

  • Download URL: djangomicroframework-0.0.3a2.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.5

File hashes

Hashes for djangomicroframework-0.0.3a2.tar.gz
Algorithm Hash digest
SHA256 9b4087a74a41d00920fc1a580434f782a378bb5de5b20cfb47a3a7288645010a
MD5 2ac48aebf6d04c2dd1fd9267cd8aa50a
BLAKE2b-256 a7358d81ed11a63e15bf5e83230ed5069df5a3d74a6fffdcbc1c27249bd6f863

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page