Skip to content

Commit 050c4b9

Browse files
committed
refac
1 parent d0188f3 commit 050c4b9

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

backend/open_webui/utils/oauth.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -536,15 +536,20 @@ def add_client(self, client_id, oauth_client_info: OAuthClientInformationFull):
536536
'server_metadata_url': (oauth_client_info.issuer if oauth_client_info.issuer else None),
537537
}
538538

539-
if oauth_client_info.server_metadata and oauth_client_info.server_metadata.code_challenge_methods_supported:
540-
if (
541-
isinstance(
542-
oauth_client_info.server_metadata.code_challenge_methods_supported,
543-
list,
544-
)
545-
and 'S256' in oauth_client_info.server_metadata.code_challenge_methods_supported
546-
):
547-
kwargs['code_challenge_method'] = 'S256'
539+
# Default to S256 for OAuth 2.1 (PKCE is mandatory per RFC 9700)
540+
kwargs['code_challenge_method'] = 'S256'
541+
542+
# Only remove PKCE if metadata explicitly excludes S256
543+
if (
544+
oauth_client_info.server_metadata
545+
and oauth_client_info.server_metadata.code_challenge_methods_supported
546+
and isinstance(
547+
oauth_client_info.server_metadata.code_challenge_methods_supported,
548+
list,
549+
)
550+
and 'S256' not in oauth_client_info.server_metadata.code_challenge_methods_supported
551+
):
552+
del kwargs['code_challenge_method']
548553

549554
self.clients[client_id] = {
550555
'client': self.oauth.register(**kwargs),

0 commit comments

Comments
 (0)