Skip to main content

django-authtkt is used to share auth between more than one django site (a kind of SSO auth)

Project description

Usage

Add the middlware class before the AuthenticationMiddleware:

MIDDLEWARE_CLASSES = (
    ...
    'authtkt.middleware.AuthTktMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    ...
)

Callback

You can use a callback to use something to fill the newly created user in the third party app.

Settings:

AUTHTKT_CALLBACK = 'yourmodule:update_user'

Callback:

from sqlalchemy import engine_from_config, Table, MetaData
from django.conf import settings


def update_user(user):
    engine = engine_from_config({'sqlalchemy.url': settings.USER_DB})
    metadata = MetaData(engine)
    users = Table('auth_user', metadata, autoload=True)
    record = users.select(users.c.id==user.id).execute().fetchone()
    for k, v in record.items():
        setattr(user, str(k), v)

Manual identify/forget user

Manualy identify user (eg: set a cookie). You need to set a correct request.user:

request.environ['authtkt.identify'](request, response)

Manualy forget user (eg: reset a cookie):

request.environ['authtkt.forget'](request, response)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

django-authtkt-0.3.zip (11.4 kB view details)

Uploaded Source

django-authtkt-0.3.tar.gz (6.0 kB view details)

Uploaded Source

File details

Details for the file django-authtkt-0.3.zip.

File metadata

  • Download URL: django-authtkt-0.3.zip
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for django-authtkt-0.3.zip
Algorithm Hash digest
SHA256 ab533760edaed7ff93ee0e036845135eb86bab46a60ae6bef363cf95ef9fcf6c
MD5 0b8f2b077caade37f44a41ab79e1f459
BLAKE2b-256 60820ea4ac751d760a1d22eff86e85e58dbe491ed585d9bcf92ec9a13933406f

See more details on using hashes here.

File details

Details for the file django-authtkt-0.3.tar.gz.

File metadata

File hashes

Hashes for django-authtkt-0.3.tar.gz
Algorithm Hash digest
SHA256 339c30ff5da1500784e173c1cc15894e03d2e0270ddcf339ba7ca90ea6d4d652
MD5 4d77874c70b16ea38764b60367d20aec
BLAKE2b-256 acc83736057656386b35f04f255cf384ba321c063317e971c605accb1063df26

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