-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: new cookie flag preventing auth cookie from being stored #36
Conversation
As of UniFi Protect 4.0.5, they have started sending the cookie flag "partitioned". Python currently does not know about this (planned to be fixed in 3.13 python/cpython#112713). This causes the cookie to be considered invalid, and thus the auth cookie is never saved. Since unifi protect rate limits authentication attempts this leads to 501 errors after a few requests are made. This commit adds `partitioned` to the list of cookie flags the standard library accepts as valid. Thus allowing the cookie to be correctly parsed and saved.
WalkthroughThe change in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/uiprotect/api.py (1 hunks)
Additional comments not posted (2)
src/uiprotect/api.py (2)
68-73
: Ensure compatibility with Python versions prior to 3.13 by handling the 'partitioned' cookie flag.This change is crucial for maintaining compatibility until Python 3.13 is released, which will natively support the 'partitioned' flag. The reference to the Python issue provides good context and justification for this temporary fix.
74-74
: Define constants for token cookie expiration and a placeholder for never run tasks.Defining these constants improves code readability and maintainability by replacing magic numbers with descriptive names. This is a good practice in coding standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ep1cman
Codecov ReportAttention: Patch coverage is
|
Tooling will auto release 1.0.1 shortly. It would be great if you could open a PR to bump the library in HA as well. |
As of UniFi Protect 4.0.5, they have started sending the cookie flag "partitioned". Python currently does not know about this (planned to be fixed in 3.13 python/cpython#112713). This causes the cookie to be considered invalid, and thus the auth cookie is never saved. Since unifi protect rate limits authentication attempts this leads to 501 errors after a few requests are made.
This commit adds
partitioned
to the list of cookie flags the standard library accepts as valid. Thus allowing the cookie to be correctly parsed and saved.Summary by CodeRabbit
TOKEN_COOKIE_MAX_EXP_SECONDS
andNEVER_RAN
.