Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent/override authorization header in Safari?

I have web page under / which requires Basic auth. Under /api/* REST API is served which does require JWT token passed in Authorization header.

In Chrome it works fine: when I load web page it asks me for Basic credentials and then webpage performs AJAX requests to /api/* along with JWT in Authorization header.

In Safari however, all AJAX requests are sent with Authorization header set to Basic credentials, and does not allow to set JWT in Authorization header...

Is there any workaround for this situation?

I am setting JWT for AJAX requests like this:

$.ajaxSetup({
  headers: {'Authorization': accessToken}
});
like image 922
user606521 Avatar asked Apr 22 '16 09:04

user606521


People also ask

How do I hide Authorization header in browser?

To make your application secure, use HTTPS, and if you really do not want to show which header is the authentication, replace it with a custom header. Also, if you really need to hide the data inside it, encrypt the token with a custom logic.

Is Authorization header automatically sent?

The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a protected resource. The Authorization header is usually, but not always, sent after the user agent first attempts to request a protected resource without credentials.

How do I pass the Authorization header in GET request?

To send a GET request with a Bearer Token authorization header, you need to make an HTTP GET request and provide your Bearer Token with the Authorization: Bearer {token} HTTP header.


1 Answers

I had this problem and probably it's a bug in Safari.

The request from Safari:

enter image description here

The same request in Wireshark:

enter image description here

Solution: don't use basic auth or change the authorization header name (e.g. use X-My-Api-Auth).

like image 101
Anton Shurashov Avatar answered Sep 20 '22 05:09

Anton Shurashov