How to conditionally disable authentication component? #1142
olivierauverlot
started this conversation in
General
Replies: 3 comments 6 replies
-
|
Use SELECT 'authentication' AS component,
'your_password_hash' AS password_hash,
:password AS password
WHERE sqlpage.request_method() != 'OPTIONS';This allows OPTIONS requests (CORS preflight) to pass through unauthenticated while maintaining security for GET/POST requests. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
You most likely do not want to disable authentication. The request you are mentioning is probably a cors preflight: |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
@olivierauverlot The easiest fix is to host the swagger ui on the same domain as the api itself |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm developing a RESTful API using SQLPage and have created a Swagger file to document the API.
I'm experiencing an issue with two services that use HTTP Basic Authentication to restrict access. These services employ an authentication component.
When Swagger UI attempts to test the service, it first sends an OPTIONS request followed by a GET request. Since the service is password-protected and Swagger UI does not transmit credentials with the OPTIONS verb, the service returns a 401 error code.
How can I disable authentication specifically for OPTIONS requests?
Best regards
Olivier
Beta Was this translation helpful? Give feedback.
All reactions