Skip to main content

The ISS (International Space Station) aims to be a space station (client) of connection between the microservices of its ecosystem and the authentication and permissions microservice of the user that here is called in the script as Hub.permissions modules / microservices (Hub)

Project description

django-hub-sdk

PyPI PyPI - Python Version Django Hub SDK

What Is This?

The ISS (International Space Station) aims to be a space station (client) of connection between the microservices of its ecosystem and the authentication and permissions microservice of the user that here is called in the script as Hub.permissions modules / microservices (Hub)

How To Use This

Installation

pip install django-hub-sdk

or if you are using Pipenv or Poetry

pipenv install django-hub-sdk
poetry add django-hub-sdk

Settings

Add the app to installed apps

INSTALLED_APPS = [
    ...,
    "django_hub_sdk",
    ...,
]

All settings can be modified through environment variables, so if you are using .env please use it.

Mandatory Settings

import os 

HUB_APP_SLUG = "" # project name on the hub

HUB_BASE_URI = os.environ.get("HUB_BASE_URI", "") # HUB backend url
HUB_BASE_FRONT_URI = os.environ.get(
    "HUB_BASE_FRONT_URI", "" # HUB frontend url
)

HUB_PROGRAMMATIC_CLIENT = os.environ.get("HUB_PROGRAMMATIC_CLIENT", "") # Programmatic user access public key
HUB_PROGRAMMATIC_SECRET = os.environ.get("HUB_PROGRAMMATIC_SECRET", "") # Programmatic user access private key

HUB_OAUTH_CLIENT_ID = os.environ.get("HUB_OAUTH_CLIENT_ID", "") # Public oauth access key
HUB_OAUTH_CLIENT_SECRET = os.environ.get("HUB_OAUTH_CLIENT_SECRET", "") # Private oauth access key
HUB_OAUTH_REDIRECT = os.environ.get("HUB_OAUTH_REDIRECT", "") # oauth access return URL

User Model

To continue the installation, in your User model extend the class below to be able to create the necessary relationships with the HUB

from django.contrib.auth.models import AbstractUser

from django_hub_sdk.models import BaseHubUser # <- Import BaseHubUser


# Create your models here.
class User(AbstractUser, BaseHubUser): # <- Extends this on model
    ...

Urls

Add this line to your urls.py to work with the frontend SDK

from django.urls import path, include

urlpatterns = [
    path("api/", include("django_hub_sdk.urls", namespace="django_hub_sdk"))
]

Use of Authorization

Use of authorizations to use the JWT generated by the Hub

from django_hub_sdk.authentication import HubJWTAuthentication # Import from package

from rest_framework import views

class LogoutView(views.APIView):
    authentication_classes = [HubJWTAuthentication] # <- Use on authentication_classes

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

django_hub_sdk-0.1.20.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

django_hub_sdk-0.1.20-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file django_hub_sdk-0.1.20.tar.gz.

File metadata

  • Download URL: django_hub_sdk-0.1.20.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.13 Linux/6.5.0-1022-azure

File hashes

Hashes for django_hub_sdk-0.1.20.tar.gz
Algorithm Hash digest
SHA256 704edd7a639038d90995583cb6731473797d89f5f6e03f187e56ed8b4e02c993
MD5 3fe58f4a88d1bc0e61242c28ae496daa
BLAKE2b-256 0adca510fcb5083a1eca2febfa6e3c9deadcf073c7dbecbf8ab71ba5ba36f32f

See more details on using hashes here.

File details

Details for the file django_hub_sdk-0.1.20-py3-none-any.whl.

File metadata

  • Download URL: django_hub_sdk-0.1.20-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.13 Linux/6.5.0-1022-azure

File hashes

Hashes for django_hub_sdk-0.1.20-py3-none-any.whl
Algorithm Hash digest
SHA256 84dbbebb03121d7ae9fa79979a92c66c3f82db912488b115959a5d08835e6da0
MD5 5ddbddde7f9178132a281343f8bf9048
BLAKE2b-256 20d0bff0b16bf94f6f4cee533b404bdd36191c63e0747581e139b6a0acea028c

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