So I'm trying to implement the following scenario:
- An application is protected by Basic Authentication. Let's say it is hosted on
app.com
- An HTTP proxy, in front of the application, requires authentication as well. It is hosted on
proxy.com
The user must therefore provide credentials for both the proxy and the application in the same request, thus he has different username/password pairs: one pair to authenticate himself against the application, and another username/password pair to authenticate himself against the proxy.
After reading the specs, I'm not really sure on how I should implement this. What I was thinking to do is:
- The user makes an HTTP request to the proxy without any sort of authentication.
- The proxy answers
407 Proxy Authentication Required
and returns aProxy-Authenticate
header in the format of:"Proxy-Authenticate: Basic realm="proxy.com"
.
Question: Is thisProxy-Authenticate
header correctly set? - The client then retries the request with a
Proxy-Authorization
header, that is the Base64 representation of the proxyusername:password
. - This time the proxy authenticates the request, but then the application answers with a
401 Unauthorized
header. The user was authenticated by the proxy, but not by the application. The application adds aWWW-Authenticate
header to the response likeWWW-Authenticate: Basic realm="app.com"
. Question: this header value is correct right? - The client retries again the request with both a
Proxy-Authorization
header, and aAuthorization
header valued with the Base64 representation of the app'susername:password
. - At this point, the proxy successfully authenticates the request, forwards the request to the application that authenticates the user as well. And the client finally gets a response back.
Is the whole workflow correct?