X-CSRFToken header causes CORS error when used with openIdConnect
security definition
#588
Labels
bug
Something isn't working
fix confirmation pending
issue has been fixed and confirmation from issue reporter is pending
Describe the bug

X-CSRFToken header causes CORS error when used with
openIdConnect
security definitionTo Reproduce
I'm using custom scheme for Keycloak OpenID auth (more info here)
For simplicity let's assume we need only
profile
scope for all the endpointsWhen we open swagger-ui, it fails to get OpenID configuration due to rather specific
X-CSRFToken
header which most Keycloak servers deny. And, of course there is no way to contact admins to change their CORS policy.It seems like it happens because of requestInterceptor here
drf-spectacular/drf_spectacular/templates/drf_spectacular/swagger_ui.js
Lines 11 to 14 in 31e7698
As far as I understand it is added for Django session authentication. But I am not sure it is the only reason.
And I am not really sure if I can override this behaviourUPD: Workaround
I managed to find some workaround. Thanks to this commit I can set
requestInterceptor
toundefined
. This seems to work, however it's quite dirty hack.UPD2: Setting
requestInterceptor
toundefined
was not a good idea as it brakes something in the UI itself. More safe way is to set"requestInterceptor": (request) => request
Expected fix
This can be fixed if we do not set requestInterceptor globally.
The text was updated successfully, but these errors were encountered: