Keycloak Integration [message #1859181] |
Thu, 18 May 2023 02:09  |
Eclipse User |
|
|
|
Hello,
I have developed a web application using Xtext. This application makes HTTP calls to an API using axios, both from the front end and the back end. To enhance security, I have decided to implement a Keycloak adapter for the front end.
Now, I need to figure out how to pass the idToken from the front end to the back end. Can you please provide guidance on this?
|
|
|
|
|
Re: Keycloak Integration [message #1859184 is a reply to message #1859183] |
Thu, 18 May 2023 04:03  |
Eclipse User |
|
|
|
maybe you can try to override the sendRequest method using javascript means or you directly patch the xtext js files
(i am not a javascript wizard)
require(["webjars/ace/1.3.3/src/ace"], function() {
require(["xtext/xtext-ace"], function(xtext) {
var cs = xtext.createServices;
if (cs) {
xtext.createServices = function(editor, options) {
const s = cs.call(this, editor, options);
for (const property in s) {
const oldSendRequest = s[property].sendRequest;
if (oldSendRequest) {
editor.xtextServices[property].sendRequest = function(editorContext, settings, needsSession) {
self = this;
settings.data.dullydully="Hello";
oldSendRequest.call(self, editorContext, settings, needsSession);
}
}
}
return s;
}
}
var editor = xtext.createEditor({
baseUrl: baseUrl,
syntaxDefinition: "xtext-resources/generated/mode-mydsl"
});
});
});
or does the token need to be send in header?
then maybe something like
//assuming this does not strip anything, otherwise maybe call original beforeSend
settings.beforeSend = function(xhr){xhr.setRequestHeader('X-Test-Header', 'test-value');};
maybe you can also do it globally with
$.ajaxSetup({
beforeSend: function(xhr) {
xhr.setRequestHeader('X-Test-Header', '...');
}
});
[Updated on: Thu, 18 May 2023 04:46] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03396 seconds