feat(session): warn about the token_source_priority and use_bearer_token changes in 0.3.9 - #378
Merged
Merged
Conversation
…ken changes in 0.3.9 0.4.0 makes token_source_priority name every token source, with the default ["header", "bearer", "cookie"], and a list without "cookie" disables the session cookie (#75). The list now accepts "cookie" as its last entry, where the cookie is read today, and FastAPICacheXSessionMiddleware emits a FutureWarning when the list was set explicitly without it. use_bearer_token duplicates the list and is removed in 0.4.0 (#377); passing it now emits a DeprecationWarning.
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.
Refs #75, #377. The removals themselves stay in 0.4.0; this adds the 0.3.9 notices, since 0.3.9 is the last 0.3.x.
Summary
token_source_priorityaccepts"cookie", but only as the last entry. That is where the cookie is read today, so listing it changes nothing yet; any other position raises aValidationError. The deprecatedSessionMiddlewareignores the entry.FastAPICacheXSessionMiddlewareemits aFutureWarningwhentoken_source_prioritywas set explicitly without"cookie". In 0.4.0 such a list disables the session cookie. The default list does not warn, since 0.4.0's default["header", "bearer", "cookie"]resolves tokens in the same order.SessionConfig(use_bearer_token=...)emits aDeprecationWarning, whatever its value. The message names the replacement.SESSION.md: the config reference and thetoken_source_prioritysection.MIGRATING_0_4.md: the summary table rows (Allow cookies in token_source_priority #75 now markedFutureWarning, a new 0.4.0: remove SessionConfig.use_bearer_token in favour of token_source_priority #377 row) and the "Token sources" section.75.deprecated.mdand377.deprecated.md.Tests
tests/session/test_0_4_0_notices.pycovers:"cookie";use_bearer_tokenwarning forTrueandFalse, and silence without it.use_bearer_token=Falsetests now expect the deprecation warning. The "unknown source" tests use"query", since"cookie"is now a known entry.--strict.