fix(auth): миграция get_qr на новый Passport BFF (fixes #747)#762
Open
trudenboy wants to merge 1 commit intoAlexxIT:masterfrom
Open
fix(auth): миграция get_qr на новый Passport BFF (fixes #747)#762trudenboy wants to merge 1 commit intoAlexxIT:masterfrom
trudenboy wants to merge 1 commit intoAlexxIT:masterfrom
Conversation
The legacy /registration-validations/auth/password/submit endpoint has started returning 400 Bad Request + captcha HTML for non-browser clients, which breaks QR login for every user (see AlexxIT#747, AlexxIT#761). The new Passport BFF accepts the same inputs but: - expects the page CSRF in the X-CSRF-Token header (not form body) - requires explicit Origin/Referer headers - splits the flow into two calls: multistep_start (get track_id) then password/submit (get per-track csrf_token) The legacy /auth/new/magic/status/ polling endpoint is unchanged and still consumes the per-track csrf_token from step 3, so login_qr is not touched. Cookie login and the request() retry/csrf machinery are also not touched — only get_qr needed the BFF migration. Closes AlexxIT#747.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что делает PR
Переводит
YandexSession.get_qrсо старого эндпоинта/registration-validations/auth/password/submitна новый Passport BFF/pwl-yandex/api/passport/*.Закрывает #747 (и дубль #761).
Проблема
Яндекс начал отдавать 40x вместо JSON на legacy
/registration-validations/auth/password/submit, Логин через куки (mobileproxy.passport.yandex.net/1/bundle/oauth/token_by_sessionid) не затронут и продолжает работать — именно поэтому cookie-метод сейчас единственный рабочий обход в треде.Решение
Фронтенд Passport уже сам переехал на новый BFF
/pwl-yandex/api/passport/*. Этот BFF принимает те же данные, но:X-CSRF-Token, а не в form-поле.Origin/Referer.POST /pwl-yandex/api/passport/auth/multistep_start→track_idPOST /pwl-yandex/api/passport/auth/password/submitсwith_code=1→ per-trackcsrf_tokenLegacy-эндпоинт поллинга
/auth/new/magic/status/не менялся и всё так же использует per-trackcsrf_tokenиз шага 3, поэтомуlogin_qrне трогаем.Diff в двух словах
GET /am?app_platform=android→ page CSRF из HTMLPOST /pwl-yandex/api/passport/auth/multistep_start(заголовокX-CSRF-Token) →track_idPOST /registration-validations/auth/password/submitсcsrf_token+retpath+with_code=1в form-body →track_id+ per-trackcsrf_tokenPOST /pwl-yandex/api/passport/auth/password/submitс заголовкомX-CSRF-Token+track_id/with_code/retpathв form-body → per-trackcsrf_token/auth/new/magic/status/Cookie-логин, retry/csrf-механика в
request()и все остальные флоу не тронуты — миграция нужна только вget_qr.Референс
Я выделил те же auth-флоу Яндекс Passport в отдельную async-библиотеку и пару дней назад отвалидировал эту BFF-миграцию против живого Passport в рамках параллельной задачи для Music Assistant:
flows/qr.py)Формат эндпоинтов/заголовков из этого PR совпадает с тем, что сейчас в этой библиотеке, и уже прогоняется реальными пользователями через QR-логин end-to-end.