poem icon indicating copy to clipboard operation
poem copied to clipboard

Swagger UI doesn't send cookie to backend

Open chikko80 opened this issue 2 years ago • 4 comments

I've defined a security schema that extracts a refresh token from the cookie.

#[derive(SecurityScheme)]
#[oai(
    type = "api_key",
    key_name = "refresh_token",
    in = "cookie",
    checker = "valid_refresh_token"
)]
pub struct UserWithValidRefreshToken(User);

The cookie is present in the browser and the request runs fine if u do the curl request and append the cookie value manually. However, if I try to trigger the endpoint via the SwaggerUI, the backend doesn't receive any cookie. What am I missing here?

chikko80 avatar Dec 10 '22 13:12 chikko80

Important to be fixed... https://swagger.io/docs/specification/authentication/cookie-authentication/

TheCataliasTNT2k avatar Dec 22 '22 17:12 TheCataliasTNT2k

It does not, because this is not really possible. See link above:

Note for Swagger UI and Swagger Editor users: Cookie authentication is currently not supported for "try it out" requests due to browser security restrictions. See this issue for more information. SwaggerHub does not have this limitation.

You can use Postman, Insomnia and all of these instead.

TheCataliasTNT2k avatar Jan 08 '23 23:01 TheCataliasTNT2k

@TheCataliasTNT2k

Mhm, do you think we should close this?

chikko80 avatar Jan 08 '23 23:01 chikko80

No. This can not "repair" the functionality within the browser right now, but the feature is still missing in poem. There is a possibility to add it to swagger, so it should be done. When it works within the browser, this feature will be helpful, but for documentary reasons it is definitely a good idea, to inplement it even before that.

TheCataliasTNT2k avatar Jan 09 '23 01:01 TheCataliasTNT2k