Repository navigation
fix(auth): require type=access in /me - #81
Merged
Merged
Conversation
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.
Closes #76
Summary
GET /api/v1/auth/meпринимал любой валидный по подписи иexpJWT как identity — в том числе 7-дневный refresh-токен. Теперь хендлер требуетpayload.get("type") == "access"сразу послеdecode_token, до извлеченияsubи запроса в БД. Refresh-токен получает 401 без раскрытия личности и без обращения к БД.Инвариант «refresh-токен — не identity» уже поддерживался Go-мидлварями гейтвея (#53) и зеркальной проверкой в
POST /refresh(type == "refresh") — этот PR закрывает последнюю щель в Python-сервисе auth.Acceptance criteria (issue #76)
/meс refresh-токеном → 401, identity не утекает, запрос к БД не выполняется/meс access-токеном → 200 (существующийtest_me_success)Changes
services/auth/src/routers/auth.py— type-check в хендлереme(3 строки)services/auth/tests/test_auth.py— регрессионный тестtest_me_with_refresh_token_rejected(refresh → 401 +db.executeни разу не вызван)Verification
uv run pytest tests/test_auth.py -v— 19 passeduv run flake8 src tests— cleanuv run mypy src— cleanblack --check tests/test_auth.py— fail на пре-существующих длинных строках, уже присутствующих наorigin/main(провереноgit show origin/main:... | black --check -); данный PR их не добавляетReview
Independent review (iteration 1): no findings — type-check стоит после проверки подписи/exp и до любых побочных эффектов; подделка
typeломает подпись; токены безtypefail closed (безопасный дефолт); других вызывающихdecode_tokenбез type-check нет.Remaining risks
None.
make e2eне гонялся — изменение покрыто юнит-тестами на границе парсинга токена, e2e-флоу auth не менялся.