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.4.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

pirates-0.4.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pirates-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 8cd50f94706e11482fb664173bb3a704075aa2b8c0102e974b7662ee608d668e
MD5 733975c124a3b12e88e6098033f51f48
BLAKE2b-256 a69b5ff0a120b9fdab9e573436f01ca13d756d834dcfeabd8ed5812f2343c829

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pirates-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e7c21c2fc3c1bf38503afc7136d13df922b10688ad5c202d639d567a37aba1cc
MD5 b972548b86cbdd7b3c3093d56c5d89e6
BLAKE2b-256 36a55d22b2b8763c04561a32c4a54ae3eee3641b2e108cac58704ebbb1a395ba

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