Skip to main content

A Django app is used to manage django auth using a token from a external source.

Project description

External JWT Token Shared Security

This django app is used to manage django auth using a token from a external source. Like a auth microservice

Quick start

  1. Add "shared_security" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'shared_security',
    ]
    
  2. Add on your django projects settings a var named JWT_SECRET_KEY with the secret key of your external jwt generator source. We recommend using a environment variable instead of writing to code directly on settings.py for security reasons

  3. Include the shared_security URLconf in your project urls.py like this:

    path('token/', include('shared_security.api.urls')),

  4. Start the django development server.

  5. To use the authentication on your API

    • Add the authentication class on REST_FRAMEWORK variable on django rest framework settings as:

      REST_FRAMEWORK = {
          ...
      
          'DEFAULT_AUTHENTICATION_CLASSES': [
              "shared_security.authentication.ExternalTokenAuthentication",
          ],
          ...
      }
      
    • Add to specific django rest view as:

      from shared_security.authentication import ExternalTokenAuthentication
      
      class YourView(viewsets.ViewSet):
      """
      A awesome view
      """
      
      authentication_classes = [ExternalTokenAuthentication,]
      
      ...
      
  6. Visit http://127.0.0.1:8000/security/user passing on header Authentication Bearer <external_jwt_token> to get user info using decode data from token.

Configuration Vars

SECURITY_USE_PERSISTENT_USERS: Boolean var to specify if you want to use your auth with the creation and update of users on the database. Important to use the django admin application the vars need to be set to true.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django-external-jwttoken-shared-security-0.1.tar.gz.

File metadata

File hashes

Hashes for django-external-jwttoken-shared-security-0.1.tar.gz
Algorithm Hash digest
SHA256 b83316501537b958891d2efa5b55193d096ebe50f60d77381a5e0a37f933ae22
MD5 73930ccc61d7210c40b8e8fec4fd7205
BLAKE2b-256 372ae783ef85d3da8ea4494c456a2c969ab3530012d11c82e3b4dba9ba068dd8

See more details on using hashes here.

File details

Details for the file django_external_jwttoken_shared_security-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_external_jwttoken_shared_security-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c511a6921b3f58d6a086c9200399916d7dde846c992c31955c4af7709277d5f
MD5 5f7c785cea5c269c21c6c013c3312087
BLAKE2b-256 7398013d38f652b850801423d8c83f751b6e88636f6a472fc0e4d4968da4185c

See more details on using hashes here.

Supported by

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