How to prevent safari showing login form when calling a restful api with HTTP basic Authentication

StackOverflow https://stackoverflow.com/questions/21542691

Frage

In my project my client side web application calls my back-end server which is a restful API sercured with HTTP baisc authentication, it runs perfect in chrome and firefox, but within the safari it always shows the HTTP basic login form, how could I prevent it to pop up in the client side.

And the client side app validates user login by calling the restful api and returns 401 automatically at the begining.

enter image description here

Keine korrekte Lösung

Andere Tipps

See an analysis of the problem here.

We had the same problem only with a recent Safari version (all other versions were fine), and the cleanest fix was to modify the "www-authenticate" header so that it doesn't return a Basic or Digest challenge.

Thus, the API url will never trigger the popup (whether it's called via Ajax or directly). Up to you to decide whether it's okay for your use case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top