Skip to main content

Django app for users, teamds and groups.

Project description

Pirates

Django app na uživatele, týmy a skupiny, s napojením na LDAP a SSO.

code style: Black license MIT Python Version Django Version

Použití

Settings

Přidat pirates do INSTALLED_APPS.

Modely

Jsou k dipozici abstraktní modely pro uživatele, tým a organizační skupinu. Ty lze doplnit o další fieldy specifické pro aplikaci. Příklad:

from django.db import models
from pirates.models import AbstractUser

class CustomUser(AbstractUser):
    is_friendly = models.BooleanField(default=True)

A nezapomenout model pro uživatele nastavit v settings:

AUTH_USER_MODEL = "myapp.CustomUser"

URLs

URL patterns (v současné době pouze pro OpenID Connect) jsou definovány v pirates.urls. Stačí je připojit k URL patterns projektu:

from pirates.urls import urlpatterns as pirates_urlpatterns 

urlpatterns = [
    # URL patterns projektu
    # ...
] + pirates_urlpatterns

SSO přes OpenID Connect

Implementaci OpenID zajišťuje knihovna mozilla-django-oidc.

V settings projektu je třeba nastavit několik konfiguračních konstant a autentifikační backend. Příklad settings (s využitím django-environ):

from os.path import join
import environ

env = environ.Env()

AUTHENTICATION_BACKENDS = ["pirates.auth.PiratesOIDCAuthenticationBackend"]

OIDC_RP_CLIENT_ID = env.str("OIDC_RP_CLIENT_ID")
OIDC_RP_CLIENT_SECRET = env.str("OIDC_RP_CLIENT_SECRET")
OIDC_RP_REALM_URL = env.str("OIDC_RP_REALM_URL")
OIDC_RP_SIGN_ALGO = "RS256"
OIDC_OP_JWKS_ENDPOINT = join(OIDC_RP_REALM_URL, "protocol/openid-connect/certs")
OIDC_OP_AUTHORIZATION_ENDPOINT = join(OIDC_RP_REALM_URL, "protocol/openid-connect/auth")
OIDC_OP_TOKEN_ENDPOINT = join(OIDC_RP_REALM_URL, "protocol/openid-connect/token")
OIDC_OP_USER_ENDPOINT = join(OIDC_RP_REALM_URL, "protocol/openid-connect/userinfo")

URL patterns pro OpenID Connect už jsou součástí pirates.urls (viz výše).

Signál po přihlášení

Po přihlášení uživatele je poslán signál pirates.signals.post_login s parametry:

  • sender - PiratesOIDCAuthenticationBackend
  • user - přihlášený uživatel (instance AUTH_USER_MODEL)
  • created - True/False zda-li byl vytvořen nový uživatel
  • request - instance HttpRequest

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

pirates-0.5.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pirates-0.5.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file pirates-0.5.0.tar.gz.

File metadata

  • Download URL: pirates-0.5.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

File hashes

Hashes for pirates-0.5.0.tar.gz
Algorithm Hash digest
SHA256 8f4673fe8f9e43803462d91d22bf37c25260356489c2e486876aa40c6fbc71e1
MD5 8d5f543ca7cedc2964e61f24a8381b88
BLAKE2b-256 bf0f7745b7048cb6d7e7edbc61bbc4598da5a6a6cadc4ec883fcc2b6f8301e5f

See more details on using hashes here.

File details

Details for the file pirates-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pirates-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.3

File hashes

Hashes for pirates-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0693b07781bc3ff71f6a8b5e50455fa794c446af13c61f7be2abd8626af17617
MD5 699a9cd42eb397ee4dd50cc8f4b0b3ba
BLAKE2b-256 e3877011da3978449ed0c97bddd68f85a9728ca39851a2dca473bc25ff3efe14

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