ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
137 stars 85 forks source link

Rust SDK does not set ACCEPT header #301

Open tomtom5152 opened 9 months ago

tomtom5152 commented 9 months ago

Preflight checklist

Ory Network Project

No response

Describe the bug

When using kratos-client-rust in WASM, the ACCEPT header is set to */* for all requests, resulting in 303 redirect requests on browser flow endpoints.

It is unclear if this is as a result of a lack of functionality in openapi-generator or if the custom Ory templates do not include the necessary lines as the header is set in other SDKs.

This could also be by design, however there is no way to set the ACCEPT header meaning the browsers tested will automatically follow the 303 response in the AJAX request, and other SDKs such as Go do explicitly set this to application/json.

Reproducing the bug

  1. Setup self hosted kratos
  2. call ory_kratos_client::apis::frontend_api::create_browser_login_flow from a rust project, specifically WASM
  3. Observe a XHR request with Accept: */*
  4. Receive a 303 response redirecting to the login UI as if directly accessed from the browser instead of the expected 200 with JSON response.

Relevant log output

No response

Relevant configuration

No response

Version

1.0.0

On which operating system are you observing this issue?

Other

In which environment are you deploying?

Other

Additional Context

Running in a Yew v0.21.0 Rust WASM app bundled with Trunk v0.17.5.

Tested against Kratos 1.0.0 in Chrome 118.0.5993.117 and Safari 17.0 on macOS, however the line parameters are missing from the generated rust sources meaning it could be undefined behavior.

tysen commented 8 months ago

You can set the default_headers of the reqwest::Client (when you build it) in the Configuration struct you pass to e.g. create_browser_login_flow.