Safe way to authentication users with REST I can authentication and login user with below code in Jquery

$.ajax({
    url : "http://domain.com/user/login",
    type : 'post',
    data : 'form_id=user_login_form&amp;name=' + encodeURIComponent("user") + '&amp;pass=' + encodeURIComponent("password"),
    dataType : 'json',
    error : function(data) {
            //error code
    },
    success : function(data) {
      console.log(data);
        //success code
    }
});


But is seems this is not safe mode, and I think maybe someone can attack  bruteforce to find users password.I want to know is this method safe(I don't think so) and what is solution for make this safe against brute-force login attack.

This Ajax request don't return any Json output,It seems try to login and if authorized  then get /user/uid

 

Note "User login REST format" is similar, but it's not duplicate, and it doesn't have an accepted answer.
Probably because you're a header, should be like this:





{ 
    "_links": {
        "type": { 
            "href": "https://yoursite.com/rest/type/node/article"
    }
  },
  "title": [{"value": "test title"}],
  "body": [{"value": "test body"}]
}