Skip to content

Commit dc0205f

Browse files
authored
Add credential handling instructions for Swagger UI (#2285)
1 parent 8dc8c8d commit dc0205f

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

core/openapi.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,32 @@ return [
924924
> **must** be set according to the
925925
> [OpenID Connect specification](https://openid.net/specs/openid-connect-core-1_0.html).
926926

927+
## Sending Credentials with Swagger UI Requests
928+
929+
When your API is deployed behind a proxy that uses cookie-based authentication (e.g. Cloudflare
930+
Access), Swagger UI's requests may be rejected because the authentication cookie is not forwarded by
931+
default. Enabling `withCredentials` adds a `requestInterceptor` to SwaggerUIBundle that sets
932+
`credentials: 'include'` on every outgoing request, ensuring cookies are sent alongside token and
933+
CORS requests.
934+
935+
### Sending Credentials with Swagger UI Requests using Symfony
936+
937+
> [!NOTE] This feature is only available with Laravel. You're welcome to contribute the Symfony
938+
> implementation [on GitHub](https://github.com/api-platform/core).
939+
940+
### Sending Credentials with Swagger UI Requests using Laravel
941+
942+
```php
943+
<?php
944+
// config/api-platform.php
945+
return [
946+
// ...
947+
'swagger_ui' => [
948+
'with_credentials' => true,
949+
],
950+
];
951+
```
952+
927953
## Info Object
928954

929955
The [info object](https://swagger.io/specification/#info-object) provides metadata about the API

0 commit comments

Comments
 (0)