Email Auth Remote
Проект для интеграции МС авторизации с другими Django МС.
Как пользоваться
Добавить проект в INSTALLED_APPS.
# File: settings.py
INSTALLED_APPS = [
...
"rest_framework_simplejwt",
"email_auth_remote",
]
В urlpatterns добавить include("email_auth_remote.urls") перед admin.site.urls.
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("api/v1/catalog/admin/", include("email_auth_remote.urls")),
path("api/v1/catalog/admin/", admin.site.urls),
]
Установить переменные в settings.py.
# File: settings.py
## defaults:
EMAIL_AUTH_REMOTE = {
"JWT_AUTH_COOKIE": None,
"JWT_AUTH_REFRESH_COOKIE": None,
"JWT_AUTH_REFRESH_COOKIE_PATH": "/",
"JWT_AUTH_COOKIE_USE_CSRF": False,
"JWT_AUTH_COOKIE_ENFORCE_CSRF_ON_UNAUTHENTICATED": False,
"JWT_AUTH_SECURE": False,
"JWT_AUTH_HTTPONLY": True,
"JWT_AUTH_SAMESITE": "Lax",
"JWT_AUTH_COOKIE_DOMAIN": None,
"JWT_REFRESH_URL": None,
"ADMIN_LOGIN_URL": None,
"LOGOUT_URL": None,
}
## examples:
EMAIL_AUTH_REMOTE = {
"JWT_AUTH_COOKIE": "jwt_access_token",
"JWT_AUTH_REFRESH_COOKIE": "jwt_refresh_token",
"JWT_AUTH_REFRESH_COOKIE_PATH": "/",
"JWT_AUTH_COOKIE_USE_CSRF": True,
"JWT_REFRESH_URL": "http://auth:8000/api/v1/auth/token/refresh/",
"ADMIN_LOGIN_URL": "/api/v1/auth/admin/login/",
"LOGOUT_URL": "http://auth:8000/api/v1/auth/logout/",
"JWT_AUTH_COOKIE_ENFORCE_CSRF_ON_UNAUTHENTICATED": False,
"JWT_AUTH_SECURE": False,
"JWT_AUTH_HTTPONLY": True,
"JWT_AUTH_SAMESITE": "Lax",
"JWT_AUTH_COOKIE_DOMAIN": None,
}
Добавить класс аутентификации
# File: settings.py
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": [
"email_auth_remote.authentication.JWTStatelessCookieAuthentication",
],
}
Важная информация: При использовании библиотеки модель CustomTokenUser, полученная через request.user не будет сохранена в БД. На эту модель невозможно ссылаться через ForeignKey и тд. Сохранение в БД также невозможно.
Разрешения IsDesigner IsSeller
Всего есть 4 возможных permissions.
from email_auth_remote.permissions import (
IsDesigner,
IsSeller,
IsSellerOrReadOnly,
IsDesignerOrReadOnly,
)
class ExampleView(generics.GenericAPIView):
"""
Пример View только для продавца.
"""
permission_classes = (IsSeller,)
# other logic here ...
Сборка
Необходимо только для сборки, для интеграции не надо.
Как собрать проект локально
python3 -m pip install build
python3 -m build
Проверка собранного пакета
python3 -m pip install twine
twine check dist/*
Выкладывание проекта в PYPI
twine upload dist/*
Metadata
Release files for email-auth-remote 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| email_auth_remote-1.3.0.tar.gz | 7.0 kB | Without provenance | Details for email_auth_remote-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| email_auth_remote-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for email_auth_remote-1.3.0-py3-none-any.whl |
Total release size: 15.7 kB
Release files / email_auth_remote-1.3.0.tar.gz
| Download URL | email_auth_remote-1.3.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f2f888202a9df6ed77651158ea298cbee3127bfc9a2a5c0a2a9ffbff1d1c1e78
|
|
BLAKE2b-256 checksum How to use checksums |
eb74002e8ac9e245d0de89390bfdbb6362ee9415d6ec293ac8fb01078d4ac6a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Release files / email_auth_remote-1.3.0-py3-none-any.whl
| Download URL | email_auth_remote-1.3.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c274e97fb3fa4d36728f7b81d158d92dc47967d4c92ab5f39294a8d3fb47cfc
|
|
BLAKE2b-256 checksum How to use checksums |
a9dbb8a24630f8d2445d22c4100d948916eb5f5aec27831885013cad3299a3cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.9
|
Security for email-auth-remote 1.3.0
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.