Skip to main content

Django app for users, teams and groups.

Project description

Pirates

Django app na uživatele, týmy a skupiny, s napojením na 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.7.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

pirates-0.7.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pirates-0.7.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0

File hashes

Hashes for pirates-0.7.0.tar.gz
Algorithm Hash digest
SHA256 d018970fb9c691df1362e4114fb6920176363cdcaf85e30e4b60cc0a34784541
MD5 a944b2c3ee850d172269b99a0a63ca0d
BLAKE2b-256 4b23e35a2d1844427e38071513e053ee1d33824f9a699afd7e7f2906321b73a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pirates-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.6.0

File hashes

Hashes for pirates-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cec043b6fb07dd8c492fd5fb47d14ccc40a4ea8788df07504e3cdb7c148865d
MD5 533ce14d848067215a17b6c62a0fc5a2
BLAKE2b-256 9df8b8439f49c480acab6addb33b5c85901c88fbe97d21aa903299f1ea1ef737

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