Search code examples
javascriptjquerydjangohttp-authentication

HTTP basic authentication in javascript, jquery or django?


I'm developing a web app (A) that serves as a "front-end" to another website (B), which requires a basic HTTP authentication (i.e., the kind that pops up and asks for a username and password).

In my web app, each user will already have his username and password for B stored as part of his account for A. However, the first time the user tries to access a resource in B from A, it prompts for the username and password (but then doesn't have to anymore for the rest of the session). I want it to be so that the user never has to explicitly enter his credentials (since they are already stored in his account).

Using javascript/jquery or some Django code, is it possible to pre-emptively authenticate this user behind the scenes, for example when they log in to A? It should just be a simple matter of sending a request to some resource in B with the username and password, therefore

Thanks, I hope this question is clear.


Solution

  • I believe you can stick that straight in the URL.

    http://user:pass@server.domain.tld/dir/file.ext