Skip to content

fix(samlshield): use Bearer auth and configured timeout for async forms - #320

Draft
Kayvan-Zahiri wants to merge 1 commit into
stytchauth:mainfrom
Kayvan-Zahiri:codex/samlshield-async-form-transport
Draft

Kayvan-Zahiri wants to merge 1 commit into
stytchauth:mainfrom
Kayvan-Zahiri:codex/samlshield-async-form-transport

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

SamlShieldClient.saml.validate_async() currently fails before sending a request: SamlShieldAsyncClient sets a Bearer Authorization header but inherits AsyncClient.post_form(), which also passes Basic Auth. aiohttp rejects that combination with ValueError: Cannot combine AUTHORIZATION header with AUTH argument or credentials encoded in URL. The async SamlShield timeout is also stored but never forwarded.

Add the async counterpart of SamlShield's existing sync post_form override. Send the merged Bearer/form headers without inherited Basic Auth, pass the configured aiohttp.ClientTimeout, and reuse the existing form-response parser. Ordinary Stytch core clients and their authentication behavior are unchanged. This is hand-maintained SamlShield code, not a generated API method.

Three regression cases exercise the public validate_async method over real local HTTPS with a short-lived generated certificate, dummy token/form data, and an externally supplied aiohttp session. They verify Bearer/form wire contents, default/configured timeout forwarding, repeated calls and external-session ownership. All three raise the auth-conflict error before the fix and pass afterward. The HTTPS endpoint is a controlled transport fixture; it does not validate SAML and no real Stytch/SamlShield service is called.

Validation on Python 3.13: python -m unittest ran 67 tests successfully, with 21 integration tests skipped (46 non-skipped tests); full Black checks (199 files), mypy (199 source files), wheel/sdist builds and diff checks pass. Existing aiohttp BasicAuth deprecation and build metadata warnings remain. Developed with AI assistance and verified locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant