Jquery authentication

How do you make a jQuery Ajax call and authenticate the call before sending the request?

I did not log in, so I had to go through authentication. Security is not a problem that anyone can access, you just need to authenticate. This is just basic HTTP authentication, you can take a look at the http://lighthouseapp.com/api/the-basics API

+3
source share
3 answers

Since you will not indicate which authentication you use, I’m going to make some big assumptions about the fact that you have some kind of login / action page that you specify a username and password using those parameter names. If you have other fields - for example, hidden fields, to prevent fakes with cross-site requests, you also need to enable them. I also assume that you know that you have not authenticated yet. There are ways to detect this, but I'm not going to cover them. I also assume that you submit actions to the website, not some API that requires a separate type of authentication.

, , POST ( ) . , . - cookie .

. , AJAX ( HTTP_X_REQUESTED_WITH - ), JSON , HTML, .

cookie , AJAX - .

0

- , - auth cookie AJAX. HTTP Basic auth.

+1

If you are trying to get javascript for authentication without any user interaction, do not.

Hard encoding your authentication logic into client-accessible code can seriously undermine the security of the API. If you are going to enter username / password in your javascript, why use it at all?

If you have access to the API and you can redo the authentication, you can try the authentication system for tokens. Just my $ .02

+1
source

Source: https://habr.com/ru/post/1757353/


All Articles