Score:0

How to change the basic auth default header in nginx?

I set basic auth in my nginx

location / {
            auth_basic "Restricted Area";
            auth_basic_user_file /etc/nginx/.htpasswd;
}

So after i saved and restart nginx. The browser uses the Authorization header to pass the basic auth

But my front application also uses this header (Authorization) to create http requests to the server, causing a conflict.

Is there anyway to let nginx use another header for basic auth?

for example: Authorization_basic

HBruijn avatar
in flag
Note that basic authentication comes with many short comings and this is another one. The Authorization header is mandated by RFC standards and AFAIK web browser can't be instructed to use a different header.
Мохамед Русланович avatar
@HBruijn thank you
Nikita Kipriyanov avatar
za flag
The best you can is to use another authentication scheme (e.g. token-based) in the application, and/or use TLS client certificate authentication on the server level, where the latter has the benefit of substantially better security and can be used to implement a true 2-factor scheme (when physical security token is used for client private key storage).
Score:0
ws flag

A really bad solution would be to use Proxy Authenticate/Proxy-Authorization from one of the servers and WWW-Authenticate/Authorization from the other. While nginx would be the logical candidate as the proxy authenticator, IIRC it does not implement proxy authentication. o either you'd have to swap around the designations or offload the validation of Proxy-Authorization.

Wouldn't it just be simpler to implement WWW-authenticate in the nginx proxy and replace the Authorization header (proxy_set_header) with a static value the app will recognize?

Score:-1
us flag

A quick overview of Basic Auth.

Narrative:

Authentication

  1. A POST request is made to example.api.com/v1/auth using:

Authorization: Basic YWRtaW46bGV0bWVpbg==

  1. The successful POST response is returned with:

Authorization: Bearer f0222b68-a72d-4eb2-ac13-f6482cf484af

Authorization

  1. A POST request is made to example.api.com/v1/users using:

Authorization: Bearer f0222b68-a72d-4eb2-ac13-f6482cf484af

  1. The successful POST response is return with:

The resource.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.