Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Keycloak Integration
Keycloak Integration [message #1859181] Thu, 18 May 2023 02:09 Go to next message
Eclipse UserFriend
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 #1859182 is a reply to message #1859181] Thu, 18 May 2023 03:16 Go to previous messageGo to next message
Eclipse UserFriend
what do you mean by backend. the xtext servlet?
Re: Keycloak Integration [message #1859183 is a reply to message #1859182] Thu, 18 May 2023 04:00 Go to previous messageGo to next message
Eclipse UserFriend
yes
Re: Keycloak Integration [message #1859184 is a reply to message #1859183] Thu, 18 May 2023 04:03 Go to previous message
Eclipse UserFriend
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

Previous Topic:Xtext and (binary) backwards compatibility
Next Topic:Xtext 2.31.0.M3 is out
Goto Forum:
  


Current Time: Sat Mar 15 11:19:05 EDT 2025

Powered by FUDForum. Page generated in 0.03396 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top