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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pirates-0.6.0.tar.gz
  • Upload date:
  • Size: 6.2 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.6.0.tar.gz
Algorithm Hash digest
SHA256 a55a0b8e07bfc1a8f8e0211e3e5b96dc5d196ee36cc43d1e89e1f32fe4081146
MD5 92697226e0f671476ec6e2241aacfe40
BLAKE2b-256 87f6dec050b3d7a8f6f65bdbb64459ca08759c7eea0d9b1eca39e914ca27a808

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pirates-0.6.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.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 94752e5ce32bc42cd8196a971691c7c39bd8e61676cc88992224790bc4f9b9cf
MD5 9c7ab4632fa877f0ec564ca142cb3d20
BLAKE2b-256 1885bcf1165c9f49399a49276b45e521554b9300d78f0309bc3dfba885dd265e

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