Skip to main content

Django microservice auth SDK

Django auth DB router.

Simple database router that helps to split your main database and authentication database. This may be necessary when splitting a project into microservices. Let's say you have some Django project and want to split it into microservices. But all of your microservices need to use the same authentication database. This router will help you to do that.


How it works

  1. Django project that provides authentication also shares default database with other microservices.
  2. Other microservices may have their own databases, but they all use the same authentication database.

Which apps are routed to auth_db database?

  • contenttypes
  • sites
  • auth
  • admin
  • flatpages
  • redirects
  • auditlog
  • sessions

Models of these apps are routed to auth_db database.

These apps are hardcoded in ms_auth_router.routers.DefaultRouter.

List can be extended by adding ROUTE_APP_LABELS setting.

If you know that some reusable Django apps should be routed to auth_db database, please create an issue or pull request.

Quickstart

Add ms_auth_router to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...,
    'ms_auth_router',
    ...
]

Add DATABASE_ROUTERS setting in settings.py file or append to existing list:

DATABASE_ROUTERS = [
    'ms_auth_router.routers.DefaultRouter',
    ...
]

Add auth_db section to DATABASES:

DATABASES = {
   ...
   'auth_db': {
       'ENGINE': 'django.db.backends.sqlite3',
       'NAME': BASE_DIR / 'auth.sqlite3',
   },
   ...
}

Finally, add AUTH_DB setting:

AUTH_DB = 'auth_db'

Without this setting router will use default db connection.

Note: To get session authentication working between microservices, the SECRET_KEY setting must be the same in all microservices.

Use with custom auth app

If you're using custom auth app and want it to be routed to auth_db database, you need to add ROUTE_APP_LABELS setting:

ROUTE_APP_LABELS = ['my_custom_auth_app', ]

Metadata

Release files for dj-ms-auth-router 1.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dj-ms-auth-router 1.5.1
File Size Uploaded Provenance Actions
dj-ms-auth-router-1.5.1.tar.gz 185.0 kB Without provenance Details for dj-ms-auth-router-1.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dj-ms-auth-router 1.5.1
File Interpreter ABI Platform Actions
dj_ms_auth_router-1.5.1-py3-none-any.whl Python 3 none any Details for dj_ms_auth_router-1.5.1-py3-none-any.whl

Total release size: 190.1 kB

Release files / dj-ms-auth-router-1.5.1.tar.gz

Download URL dj-ms-auth-router-1.5.1.tar.gz
Size 185.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2779f6ad11fd93182948204febd6e301c43f18b56c0c57ee9bb5ab8f40dd3c29
BLAKE2b-256 checksum
How to use checksums
c72c825fc9cf82d72ababc6e2114e6f85f3219cafd82aa251766a0a3b9ceaa8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / dj_ms_auth_router-1.5.1-py3-none-any.whl

Download URL dj_ms_auth_router-1.5.1-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
14e833dbdad6e5b1f00784aee2ec6f696d242eb463d9515c6d84d8250da5131a
BLAKE2b-256 checksum
How to use checksums
6a522162bea82012f35de7828540a7864dca176441051aa98d6f40d37e8e0582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Security for dj-ms-auth-router 1.5.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page