Skip to main content

Official Django SDK for Syauth Authentication

Project description

Django SDK for Syauth

PyPI version License: MIT

Official Django integration for Syauth - a modern authentication platform.

Features

  • 🔐 OAuth 2.0 Authorization Code Flow with PKCE
  • 🚀 Drop-in views for Login, Callback, and Logout
  • 🔒 Secure token management
  • 🛡️ Protected routes with decorators
  • 🎨 Easy integration with Django's authentication system

Installation

pip install django-syauth

Quick Start

1. Add to INSTALLED_APPS

INSTALLED_APPS = [
    ...
    'django_syauth',
]

2. Configure Authentication Backends

AUTHENTICATION_BACKENDS = [
    'django.contrib.auth.backends.ModelBackend',
    'django_syauth.backend.SyauthBackend',
]

3. Add Syauth Settings

SYAUTH = {
    'API_URL': 'https://api.syauth.com/e/v1',
    'CLIENT_ID': 'your-client-id',
    'REDIRECT_URI': 'http://localhost:8000/auth/callback',
    'API_KEY': 'your-api-key',
    'SCOPES': ['openid', 'profile', 'email'],
    # 'CLIENT_SECRET': 'your-secret',  # Only for server-to-server clients
}

4. Include URLs

from django.urls import path, include

urlpatterns = [
    path('auth/', include('django_syauth.urls')),
    # ... your other urls
]

Usage

Protecting Views

Use the @syauth_login_required decorator to protect views:

from django_syauth.decorators import syauth_login_required

@syauth_login_required
def dashboard(request):
    return render(request, 'dashboard.html')

Template URLs

In your templates, use the named URLs:

<a href="{% url 'django_syauth:login' %}">Sign In</a>
<a href="{% url 'django_syauth:logout' %}">Sign Out</a>

Accessing User Info

After login, user information is available via request.user:

def profile(request):
    email = request.user.email
    first_name = request.user.first_name
    last_name = request.user.last_name
    # ...

Configuration Options

Setting Required Description
API_URL Syauth API URL (e.g., https://api.syauth.com/e/v1)
CLIENT_ID Your OAuth Client ID
REDIRECT_URI Callback URL (must match Syauth Dashboard)
API_KEY Your API Key from Syauth Dashboard
SCOPES OAuth scopes (default: ['openid', 'profile', 'email'])
CLIENT_SECRET Only for server-to-server (confidential) clients

Example Application

Check out the example application for a complete working demo.

Running the Example

cd examples/django-app-with-sdk

# Copy and configure environment
cp .env.example .env
# Edit .env with your Syauth credentials

# Install dependencies
pip install django requests pyjwt[crypto]

# Run migrations
python manage.py migrate

# Start the server
python manage.py runserver

Using with ngrok

For development with external OAuth providers, you may need to use ngrok. See the ngrok guide for setup instructions.

Documentation

Full documentation is available at developers.nexorix.com/syauth.

License

MIT License - see LICENSE for details.

Support

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

django_syauth-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_syauth-0.1.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file django_syauth-0.1.0.tar.gz.

File metadata

  • Download URL: django_syauth-0.1.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for django_syauth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 522b825357d31782d487842b73ad37c8c5b609e8e4a6b8006759b6f20b5e05fd
MD5 17ca3df84ecdd0d89dbd18072d6ee3c7
BLAKE2b-256 aa123e3073a1151f9697109adf1bde90cb6a791dca4160584c5873346664993b

See more details on using hashes here.

File details

Details for the file django_syauth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: django_syauth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for django_syauth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47ae0d49bade7559efc1a19c5ea03f8fca6aac1b149ad328a0130fdddd3ee443
MD5 f512bff7ec05c8ed0c635de0b69531c0
BLAKE2b-256 b4def13b3da27e951839a36222894c5b9fd256e66f9a5144b0aad597ec921b10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page