Находки в опенсорсе: Python
973 subscribers
5 photos
226 links
Легкие задачки в опенсорсе из мира Python

Чат: @opensource_findings_chat
Download Telegram
🚀 New issue to wemake-services/wemake-python-styleguide by @sobolevn
📝 Remove `WPS354` (#3601)


This rules has more problems that it solves:

1. Two yields and yield from are two different things
2. Async iterators cannot use yield from, but WPS354 still raises even in async def

So, it is time to remove this rule. I was wrong about that :(
See other rules with disabled_since attribute on how to disable a rule.


#feature #help_wanted #levelstarter #good_first_issue #wemake_python_styleguide #wps
sent via relator
🫡1
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Add `RefreshTokenSyncController` and `RefreshTokenAsyncController` (#907)


Add RefreshTokenSyncController and RefreshTokenAsyncController

Basically, they should accept refresh_token and return new pairs of access_token and refresh_token. But they should be reusable as well as the existing controllers.

It should be similar to the existing views:

django-modern-rest/dmr/security/jwt/views.py

Lines 99 to 132 in dba07e8

Example from a real project: https://github.com/Griger10/g-pulse/blob/3d520b8444736eaaeffad1cf2221019f3ffad6c4/services/api/apps/accounts/api/views.py#L93


#feature #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Convert our `Empty` class usage to `typing_extensions.Sentinel` (#995)


Current way:

django-modern-rest/dmr/types.py

Lines 48 to 55 in 5ca7975

New (modern) way: https://typing-extensions.readthedocs.io/en/latest/#typing_extensions.Sentinel

1. We need to change how EmptyObj is defined to be EMPTY: Final = Sentinel('EMPTY')
2. We need to change all isinstance(..., Empty) to check for the sentinel

This is a very easy task for new contributors :)


#feature #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Add default admin page for `dmr/security/jwt/blocklist` (#1054)


Right now our app for jwt blocklisting has a default model: https://github.com/wemake-services/django-modern-rest/blob/master/dmr/security/jwt/blocklist/models.py

But, it does not have a default admin.py file.
Good example: https://github.com/Dresdn/django-modern-rest/blob/3324d0aecf32509b5434df7e8826d7be6ddac7a8/dmr/security/token/admin.py

This is a very easy task :)


#feature #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @sobolevn
📝 Setup `lychee` link check tool for `pre-commit` (#1094)


It allows checking that all links are actually valid.
This will helps us finding dead / renamed links in the docs / code.

Hooks: https://github.com/lycheeverse/lychee/blob/master/.pre-commit-hooks.yaml
Docs: https://lychee.cli.rs/
Example config: https://github.com/msgspec/msgspec/blob/main/lychee.toml (but I would prefer to have it in the same folder as zizmor config is).


#documentation #feature #good_first_issue #help_wanted #django_modern_rest
sent via relator
🚀 New issue to wemake-services/django-modern-rest by @ZhdanovAM72
📝 Add a built-in JWT access token verification flow. (#1129)


FEATURE

Thesis

Add a built-in JWT access token verification flow.

For example, django-modern-rest could provide a reusable controller:

from dmr.security.jwt.views import VerifyTokenSyncController


class TokenVerifyController(VerifyTokenSyncController):
pass

Expected behavior:

• accept an encoded token from the request body
• decode and validate the JWT
• reject malformed tokens
• reject expired tokens
• reject refresh tokens when an access token is expected
• verify that the token subject belongs to an existing active user
• return a successful empty response when the token is valid

The exact public API can be different. It could be implemented as a controller,
auth class, or reusable JWT verification component.

Reasoning

django-modern-rest already provides JWT obtain and refresh controllers, but
applications commonly also need a token verification endpoint.

Without built-in support, each project has to implement the same logic manually:

from django.conf import settings
from dmr.exceptions import NotAuthenticatedError
from dmr.security.jwt.token import JWToken


token = JWToken.decode(
encoded_token=encoded_token,
secret=str(settings.SECRET_KEY),
algorithm="HS256",
)

if token.extras.get("type") != "access":
raise NotAuthenticatedError

user = User.objects.get(pk=token.sub)

if not user.is_active:
raise NotAuthenticatedError

This logic is not application-specific. It is part of the common JWT API
surface.

Providing it in django-modern-rest would reduce duplication and make JWT support
more complete. It would also make error handling more consistent with the
existing obtain and refresh controllers.


#feature #good_first_issue #help_wanted #django_modern_rest
sent via relator