Hi,
I have written a custom Authentication based on Sling form based Authentication. I followed http://www.wemblog.com/2013/03/how-to-create-custom-authentication.html article to do that. I am trying to invoke the handler with Ajax call and it seems like the call is never going into the handler.
But if i invoke it with CURL it invokes fine and gives me response i expect. Below CURL is being used. My Handler expects Json input of username and password.
curl -i -X POST -d '{"username":"admin","password":"admin","keepLoggedIn":true}' -H 'Content-Type: application/json' localhost:4503/j_mycustom_security_check
The Ajax call that i am doing is :
var username = "admin"; var password = "admin"; var apiURL = "http://localhost:4503/content/j_mycustom_security_check" var jsonPayload = { username: username, password: password }; $.ajax({ url: apiURL, type: "POST", data: JSON.stringify(jsonPayload), contentType: "application/json", success : function(data, status, xhr) { console.log("sucess"+status); }, error: function (xhr, ajaxOptions, thrownError) { console.log('error'+thrownError); } });
I can see the handler in handlers tab and i have added the j_mycustom_security_check in Sling Authenticator service in OSGI. Can anybody point out how can i resolve this? Thanks in advance.
When i keep the apiURL param as
http://localhost:4503/content/j_mycustom_security_check
i get 403 Forbidden response, while if i use
http://localhost:4503/content/j_mycustom_security_check.html i get success 200 always. However, in both cases my Authentication code is not getting invoked. But in case of curl it does.