chore: refacotring http auth - #100
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
==========================================
- Coverage 76.67% 76.34% -0.33%
==========================================
Files 9 9
Lines 763 761 -2
Branches 130 126 -4
==========================================
- Hits 585 581 -4
- Misses 124 125 +1
- Partials 54 55 +1
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
e3b191f to
991b5dd
Compare
|
|
||
| @model_validator(mode="before") | ||
| @classmethod | ||
| def check_username_and_password_present(cls, data: Any) -> Any: |
There was a problem hiding this comment.
shouldn't this already be done by pydantic?
|
|
||
| @model_validator(mode="before") | ||
| @classmethod | ||
| def check_token_present(cls, data: Any) -> Any: |
There was a problem hiding this comment.
same here for pydantic
| else: | ||
| logger.error("HttpAuth configuration error: %s", e) | ||
| raise e from e | ||
| raise TypeError( |
There was a problem hiding this comment.
This already includes {context}: {HTTP_AUTH_CONFIGURATION_ERROR} prefix, but the except (…, TypeError) below re-wraps it with the same prefix (then appears twice in the logs). Maybe you can raise the bare message here (raise TypeError("Auth parsing failed, expected list or dict")) and let the except add the prefix once.
991b5dd to
6d5b978
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6d5b978. Configure here.
| token: str | ||
| @dataclass | ||
| class BearerAuth: | ||
| token: str = Field(min_length=1) |
There was a problem hiding this comment.
Dict extras silently ignored
Medium Severity
BasicAuth and BearerAuth dropped extra="forbid" in the move from BaseModel to pydantic dataclasses, so unknown dict keys are discarded instead of failing config load. List-form extras still error via auth(*args), so the same typo is accepted or rejected depending on config shape.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 6d5b978. Configure here.


SYN-99
Note
Medium Risk
Changes auth config parsing and error types for OAuth introspection/notify HTTP auth, which could break misconfigured deployments that relied on empty types or empty credentials.
Overview
Refactors HTTP auth configuration parsing:
NoAuth,BasicAuth, andBearerAuthmove from PydanticBaseModeltopydantic.dataclasses, withmin_length=1on username, password, and token so empty credentials fail validation.parse_dict_authandparse_list_authare removed; dict and list shapes are handled in a singleparse_auth, with anAUTH_TYPESmap forbasic/bearer. Parse failures now raiseValueErrorwith a consistentAuth configuration error:prefix (optional configcontextin logs and messages), instead of genericException/HttpAuthwording.Behavior tightening: only
type: null(or list[null]) yieldsNoAuth; an empty string type is treated as unknown, not no-auth. Dict configs with extra keys are accepted (extras ignored); list configs still reject extra positional args.pydanticis added as a runtime dependency andpydantic.mypyis enabled in tooling.Reviewed by Cursor Bugbot for commit 6d5b978. Bugbot is set up for automated code reviews on this repo. Configure here.