%global _empty_manifest_terminate_build 0 Name: python-tamarin-utils Version: 0.15.5 Release: 1 Summary: Lamasoo utils for developing web application License: MIT License URL: https://git.lamasoo.com/crs-agency/tamarin Source0: https://mirrors.aliyun.com/pypi/web/packages/3e/c7/503f74d04d4444182c2ad5250bb4b427ca7c83348de8e98a6c304dfd59d4/tamarin-utils-0.15.5.tar.gz BuildArch: noarch Requires: python3-requests Requires: python3-djangorestframework Requires: python3-elasticsearch[async] Requires: python3-celery Requires: python3-sentry-sdk Requires: python3-dateutil Requires: python3-firebase-admin Requires: python3-google-api-python-client Requires: python3-jose Requires: python3-djangorestframework-simplejwt Requires: python3-pycryptodome Requires: python3-django-nose Requires: python3-telegram-bot Requires: python3-Pyrogram Requires: python3-TgCrypto Requires: python3-elastic-apm Requires: python3-xlwt %description # Tamarin Utils ## Sentry > settings.py ```python from tamarin import sentry ... SENTRY_KEY = '' SENTRY_ORGANIZATION = '' SENTRY_PROJECT = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = 'list of status that should capture' # default [] sentry.init() ``` or ```python from tamarin import sentry ... SENTRY_URL = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = [''] # default [] sentry.init() ``` ## Elastic search > settings.py ```python ELASTIC_PROTOCOL = '' # default 'http' ELASTIC_HOST = '' # default 'localhost' ELASTIC_PORT = '' # default 9200 ELASTIC_USE_SSL = '' # default False TIME_ZONE = '' # default 'UTC' ELASTIC_ALLOWED_STATUS = [''] # default [] ELASTIC_USER = '' # default '' ELASTIC_PASSWORD = '' # default '' ``` ## Firebase > settings.py ```python FIREBASE_APP_OPTIONS = '' # default {} FIREBASE_APP_NAME = 'your app name' # default 'FIRESTORE_DEFAULT' ``` ## Log > for use log, you must config elastic search and sentry before ## JWT Authentication in your root urls.py file (or any other url config), include routes for Tamarin’s TokenObtainPairView and TokenRefreshView views: ```python from django.urls import path from tamarin.rest.authorization import ( TamarinTokenObtainPairView, TamarinRefreshView ) urlpatterns = [ ..., path('apiv1/accounts/token/', TamarinTokenObtainPairView.as_view(), name='token_obtain_pair'), path('apiv1/accounts/refresh/', TamarinRefreshView.as_view(), name='token_refresh'), ... ] ``` ### Settings Some of Tamarin’s authentication behavior can be customized through settings variables in settings.py ```python from datetime import timedelta SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5), 'REFRESH_TOKEN_LIFETIME': timedelta(days=1), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': True, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'AUTH_HEADER_TYPES': ('Bearer',), 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'AUTH_TOKEN_CLASSES': ('tamarin.rest.authorization.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } ``` ## Database ReplicaRouter With `database.router.ReplicaRouter` all read queries will go to a replica database; all inserts, updates, and deletes will do to the ``default`` database. First, define ``REPLICA_DATABASES`` in your settings. It should be a list of database aliases that can be found in ``DATABASES``: ```python DATABASES = { 'default': {...}, 'replica-1': {...}, 'replica-2': {...}, } REPLICA_DATABASES = ['replica-1', 'replica-2'] ``` Then put ``database.router.ReplicaRouter`` into DATABASE_ROUTERS: ```python DATABASE_ROUTERS = ('tamarin.database.router.ReplicaRouter',) ``` The replica databases will be chosen in round-robin fashion. If you want to get a connection to a replica in your app, use `database.router.ReplicaRouter` ```python from django.db import connections from tamarin.database import router connection = connections[router.get_replica()] ``` ### Database PinningReplicaRouter In some applications, the lag between the primary database receiving a write and its replication to the replicas is enough to cause inconsistency for the end user. For example, imagine a scenario with 1 second of replication lag. If a user makes a forum post (to the primary) and then is redirected to a fully-rendered view of it (from a replica) 500ms later, the view will fail. If this is a problem in your application, consider using `multidb.PinningReplicaRouter`. This router works in combination with `multidb.middleware.PinningRouterMiddleware` to assure that, after writing to the `default` database, future reads from the same user agent are directed to the `default` database for a configurable length of time. `PinningRouterMiddleware` identifies database writes primarily by request type, assuming that requests with HTTP methods that are not `GET`, `TRACE`, `HEAD`, or `OPTIONS` are writes. You can indicate that any view writes to the database by using the `tamarin.database.router.db_write` decorator. This will cause the same result as if the request were, e.g., a `POST`. To use `PinningReplicaRouter`, put it into `DATABASE_ROUTERS` in your settings: ```python DATABASE_ROUTERS = ('database.router.PinningReplicaRouter',) ``` Then, install the middleware. It must be listed before any other middleware which performs database writes: ```python MIDDLEWARE_CLASSES = ( 'multidb.middleware.PinningRouterMiddleware', ...more middleware here... ) ``` `PinningRouterMiddleware` attaches a cookie to any user agent who has just written. The cookie should be set to expire at a time longer than your replication lag. By default, its value is a conservative 15 seconds, but it can be adjusted like so: ```python TAMARIN_PINNING_SECONDS = 5 ``` If you need to change the name of the cookie, use the `TAMARIN_PINNING_COOKIE` setting: ```python TAMARIN_PINNING_COOKIE = 'tamarin_pin_writes' ``` %package -n python3-tamarin-utils Summary: Lamasoo utils for developing web application Provides: python-tamarin-utils BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-tamarin-utils # Tamarin Utils ## Sentry > settings.py ```python from tamarin import sentry ... SENTRY_KEY = '' SENTRY_ORGANIZATION = '' SENTRY_PROJECT = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = 'list of status that should capture' # default [] sentry.init() ``` or ```python from tamarin import sentry ... SENTRY_URL = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = [''] # default [] sentry.init() ``` ## Elastic search > settings.py ```python ELASTIC_PROTOCOL = '' # default 'http' ELASTIC_HOST = '' # default 'localhost' ELASTIC_PORT = '' # default 9200 ELASTIC_USE_SSL = '' # default False TIME_ZONE = '' # default 'UTC' ELASTIC_ALLOWED_STATUS = [''] # default [] ELASTIC_USER = '' # default '' ELASTIC_PASSWORD = '' # default '' ``` ## Firebase > settings.py ```python FIREBASE_APP_OPTIONS = '' # default {} FIREBASE_APP_NAME = 'your app name' # default 'FIRESTORE_DEFAULT' ``` ## Log > for use log, you must config elastic search and sentry before ## JWT Authentication in your root urls.py file (or any other url config), include routes for Tamarin’s TokenObtainPairView and TokenRefreshView views: ```python from django.urls import path from tamarin.rest.authorization import ( TamarinTokenObtainPairView, TamarinRefreshView ) urlpatterns = [ ..., path('apiv1/accounts/token/', TamarinTokenObtainPairView.as_view(), name='token_obtain_pair'), path('apiv1/accounts/refresh/', TamarinRefreshView.as_view(), name='token_refresh'), ... ] ``` ### Settings Some of Tamarin’s authentication behavior can be customized through settings variables in settings.py ```python from datetime import timedelta SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5), 'REFRESH_TOKEN_LIFETIME': timedelta(days=1), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': True, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'AUTH_HEADER_TYPES': ('Bearer',), 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'AUTH_TOKEN_CLASSES': ('tamarin.rest.authorization.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } ``` ## Database ReplicaRouter With `database.router.ReplicaRouter` all read queries will go to a replica database; all inserts, updates, and deletes will do to the ``default`` database. First, define ``REPLICA_DATABASES`` in your settings. It should be a list of database aliases that can be found in ``DATABASES``: ```python DATABASES = { 'default': {...}, 'replica-1': {...}, 'replica-2': {...}, } REPLICA_DATABASES = ['replica-1', 'replica-2'] ``` Then put ``database.router.ReplicaRouter`` into DATABASE_ROUTERS: ```python DATABASE_ROUTERS = ('tamarin.database.router.ReplicaRouter',) ``` The replica databases will be chosen in round-robin fashion. If you want to get a connection to a replica in your app, use `database.router.ReplicaRouter` ```python from django.db import connections from tamarin.database import router connection = connections[router.get_replica()] ``` ### Database PinningReplicaRouter In some applications, the lag between the primary database receiving a write and its replication to the replicas is enough to cause inconsistency for the end user. For example, imagine a scenario with 1 second of replication lag. If a user makes a forum post (to the primary) and then is redirected to a fully-rendered view of it (from a replica) 500ms later, the view will fail. If this is a problem in your application, consider using `multidb.PinningReplicaRouter`. This router works in combination with `multidb.middleware.PinningRouterMiddleware` to assure that, after writing to the `default` database, future reads from the same user agent are directed to the `default` database for a configurable length of time. `PinningRouterMiddleware` identifies database writes primarily by request type, assuming that requests with HTTP methods that are not `GET`, `TRACE`, `HEAD`, or `OPTIONS` are writes. You can indicate that any view writes to the database by using the `tamarin.database.router.db_write` decorator. This will cause the same result as if the request were, e.g., a `POST`. To use `PinningReplicaRouter`, put it into `DATABASE_ROUTERS` in your settings: ```python DATABASE_ROUTERS = ('database.router.PinningReplicaRouter',) ``` Then, install the middleware. It must be listed before any other middleware which performs database writes: ```python MIDDLEWARE_CLASSES = ( 'multidb.middleware.PinningRouterMiddleware', ...more middleware here... ) ``` `PinningRouterMiddleware` attaches a cookie to any user agent who has just written. The cookie should be set to expire at a time longer than your replication lag. By default, its value is a conservative 15 seconds, but it can be adjusted like so: ```python TAMARIN_PINNING_SECONDS = 5 ``` If you need to change the name of the cookie, use the `TAMARIN_PINNING_COOKIE` setting: ```python TAMARIN_PINNING_COOKIE = 'tamarin_pin_writes' ``` %package help Summary: Development documents and examples for tamarin-utils Provides: python3-tamarin-utils-doc %description help # Tamarin Utils ## Sentry > settings.py ```python from tamarin import sentry ... SENTRY_KEY = '' SENTRY_ORGANIZATION = '' SENTRY_PROJECT = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = 'list of status that should capture' # default [] sentry.init() ``` or ```python from tamarin import sentry ... SENTRY_URL = '' SENTRY_ALLOWED_ALL = 'if true all status captured' # default False SENTRY_ALLOWED_STATUS = [''] # default [] sentry.init() ``` ## Elastic search > settings.py ```python ELASTIC_PROTOCOL = '' # default 'http' ELASTIC_HOST = '' # default 'localhost' ELASTIC_PORT = '' # default 9200 ELASTIC_USE_SSL = '' # default False TIME_ZONE = '' # default 'UTC' ELASTIC_ALLOWED_STATUS = [''] # default [] ELASTIC_USER = '' # default '' ELASTIC_PASSWORD = '' # default '' ``` ## Firebase > settings.py ```python FIREBASE_APP_OPTIONS = '' # default {} FIREBASE_APP_NAME = 'your app name' # default 'FIRESTORE_DEFAULT' ``` ## Log > for use log, you must config elastic search and sentry before ## JWT Authentication in your root urls.py file (or any other url config), include routes for Tamarin’s TokenObtainPairView and TokenRefreshView views: ```python from django.urls import path from tamarin.rest.authorization import ( TamarinTokenObtainPairView, TamarinRefreshView ) urlpatterns = [ ..., path('apiv1/accounts/token/', TamarinTokenObtainPairView.as_view(), name='token_obtain_pair'), path('apiv1/accounts/refresh/', TamarinRefreshView.as_view(), name='token_refresh'), ... ] ``` ### Settings Some of Tamarin’s authentication behavior can be customized through settings variables in settings.py ```python from datetime import timedelta SIMPLE_JWT = { 'ACCESS_TOKEN_LIFETIME': timedelta(minutes=5), 'REFRESH_TOKEN_LIFETIME': timedelta(days=1), 'ROTATE_REFRESH_TOKENS': False, 'BLACKLIST_AFTER_ROTATION': True, 'ALGORITHM': 'HS256', 'SIGNING_KEY': SECRET_KEY, 'VERIFYING_KEY': None, 'AUDIENCE': None, 'ISSUER': None, 'AUTH_HEADER_TYPES': ('Bearer',), 'USER_ID_FIELD': 'id', 'USER_ID_CLAIM': 'user_id', 'AUTH_TOKEN_CLASSES': ('tamarin.rest.authorization.AccessToken',), 'TOKEN_TYPE_CLAIM': 'token_type', 'JTI_CLAIM': 'jti', 'SLIDING_TOKEN_REFRESH_EXP_CLAIM': 'refresh_exp', 'SLIDING_TOKEN_LIFETIME': timedelta(minutes=5), 'SLIDING_TOKEN_REFRESH_LIFETIME': timedelta(days=1), } ``` ## Database ReplicaRouter With `database.router.ReplicaRouter` all read queries will go to a replica database; all inserts, updates, and deletes will do to the ``default`` database. First, define ``REPLICA_DATABASES`` in your settings. It should be a list of database aliases that can be found in ``DATABASES``: ```python DATABASES = { 'default': {...}, 'replica-1': {...}, 'replica-2': {...}, } REPLICA_DATABASES = ['replica-1', 'replica-2'] ``` Then put ``database.router.ReplicaRouter`` into DATABASE_ROUTERS: ```python DATABASE_ROUTERS = ('tamarin.database.router.ReplicaRouter',) ``` The replica databases will be chosen in round-robin fashion. If you want to get a connection to a replica in your app, use `database.router.ReplicaRouter` ```python from django.db import connections from tamarin.database import router connection = connections[router.get_replica()] ``` ### Database PinningReplicaRouter In some applications, the lag between the primary database receiving a write and its replication to the replicas is enough to cause inconsistency for the end user. For example, imagine a scenario with 1 second of replication lag. If a user makes a forum post (to the primary) and then is redirected to a fully-rendered view of it (from a replica) 500ms later, the view will fail. If this is a problem in your application, consider using `multidb.PinningReplicaRouter`. This router works in combination with `multidb.middleware.PinningRouterMiddleware` to assure that, after writing to the `default` database, future reads from the same user agent are directed to the `default` database for a configurable length of time. `PinningRouterMiddleware` identifies database writes primarily by request type, assuming that requests with HTTP methods that are not `GET`, `TRACE`, `HEAD`, or `OPTIONS` are writes. You can indicate that any view writes to the database by using the `tamarin.database.router.db_write` decorator. This will cause the same result as if the request were, e.g., a `POST`. To use `PinningReplicaRouter`, put it into `DATABASE_ROUTERS` in your settings: ```python DATABASE_ROUTERS = ('database.router.PinningReplicaRouter',) ``` Then, install the middleware. It must be listed before any other middleware which performs database writes: ```python MIDDLEWARE_CLASSES = ( 'multidb.middleware.PinningRouterMiddleware', ...more middleware here... ) ``` `PinningRouterMiddleware` attaches a cookie to any user agent who has just written. The cookie should be set to expire at a time longer than your replication lag. By default, its value is a conservative 15 seconds, but it can be adjusted like so: ```python TAMARIN_PINNING_SECONDS = 5 ``` If you need to change the name of the cookie, use the `TAMARIN_PINNING_COOKIE` setting: ```python TAMARIN_PINNING_COOKIE = 'tamarin_pin_writes' ``` %prep %autosetup -n tamarin-utils-0.15.5 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "\"/%h/%f\"\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "\"/%h/%f.gz\"\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-tamarin-utils -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri Jun 09 2023 Python_Bot - 0.15.5-1 - Package Spec generated