fix(auth): coerce empty-string optional URL fields to None in OAuthClientMetadata (#2404)
This commit is contained in:
parent
941089e06a
commit
2dfb51a4d1
1 changed files with 102 additions and 2 deletions
|
|
@ -67,6 +67,24 @@ class OAuthClientMetadata(BaseModel):
|
|||
software_id: str | None = None
|
||||
software_version: str | None = None
|
||||
|
||||
@field_validator(
|
||||
"client_uri",
|
||||
"logo_uri",
|
||||
"tos_uri",
|
||||
"policy_uri",
|
||||
"jwks_uri",
|
||||
mode="before",
|
||||
)
|
||||
@classmethod
|
||||
def _empty_string_optional_url_to_none(cls, v: object) -> object:
|
||||
# RFC 7591 §2 marks these URL fields OPTIONAL. Some authorization servers
|
||||
# echo omitted metadata back as "" instead of dropping the keys, which
|
||||
# AnyHttpUrl would otherwise reject — throwing away an otherwise valid
|
||||
# registration response. Treat "" as absent.
|
||||
if v == "":
|
||||
return None
|
||||
return v
|
||||
|
||||
def validate_scope(self, requested_scope: str | None) -> list[str] | None:
|
||||
if requested_scope is None:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue