2017 Nov 30 11:51 AM - edited 2024 Feb 04 1:27 AM
Hello,
We have developed common utilities functionality in Java application having few RESTful web services and now planning to implement X-CSRF-Token implementation to make it REST webservices more secured.
I found some information at
but some how as per the instruction given in this link is not working.
Could you please provide some Java example to generate csrf token and to consume it from UI5 application ?
Thanks.
Request clarification before answering.
Hello, Ashutosh.To pass CSRF as a parameter by using Ajax. My solution is base on JQuery. thanks
$(document).ready(function(){
function getCookie(c_name) {
if(document.cookie.length > 0) {
c_start = document.cookie.indexOf(c_name + "=");
if(c_start != -1) {
c_start = c_start + c_name.length + 1;
c_end = document.cookie.indexOf(";", c_start);
if(c_end == -1) c_end = document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
$(function () {
$.ajaxSetup({
headers: {
"X-CSRFToken": getCookie("csrftoken")
}
});
});
});
it is being fetched from the request header at the server side.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
11 | |
9 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.