Solved

Access to the authentication-cookies

  • 17 February 2023
  • 7 replies
  • 191 views

Userlevel 1
Badge +1

HI @Mark Jongeling ,

In this item you mention  The page will have access to the authentication-cookies of the GUI and therefore can make use of all of Indicium's functionalities.

Custom script integration in Universal GUI | Thinkwise Community (thinkwisesoftware.com)

Can you tell me HOW exactly this can be accessed? 

any help will be highly appreciated,

Tiago Krommendijk

icon

Best answer by Leroy Witteveen 17 February 2023, 10:29

View original

This topic has been closed for comments

7 replies

Userlevel 5
Badge +12

Also looking for this info! Interesting. 

Userlevel 3
Badge +3

Hi @tiago and @Blommetje,

This only works if the preview column is of the controltype URL.
Furthermore, it's only possible to make requests to Indicium from a same origin HTML page.
It isn't possible to get the contents of the cookie yourself, as the cookie is a HttpOnly cookie (as it should be, due to security concerns), so the browser will automatically send it along with requests to Indicium, but won't be able to read it from JavaScript.

Same origin means that when your Universal is located at “server.domain.com/universal”, your HTML page needs to be under “server.domain.com/” as well, so for example “server.domain.com/page.html”. It also needs to be on the same port. (so Universal on “server.domain.com:8080/universal” and the HTML page on “server.domain.com/page.html” won't work)

When these conditions are met, you can fetch Indicium API routes with a HTML file like this:

(I'm using fetch here as an example, it might be better to use an abstraction library instead, depending on your needs)

Then, when opening the Preview component, it will look like this:


Kind regards,
Leroy Witteveen

Userlevel 5
Badge +16

@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in? 

Userlevel 3
Badge +3

@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in? 

Hi Freddy,

What kind of context do you want to access exactly?

Kind regards,
Leroy Witteveen

Userlevel 5
Badge +16

@Leroy Witteveen is there also a way to find out the context the iframe of the previewer is loaded in? 

Hi Freddy,

What kind of context do you want to access exactly?

Kind regards,
Leroy Witteveen

For example, I'm adding the URL for the previewer with the custom page in a certain table..  in our case a service..  Is there a way to query the context or does the url need something like page.html?var1=bla&var2=aat ?

Userlevel 3
Badge +3

Hi @Freddy,

You could achieve this by creating an expression field which appends e.g. ?subject=employee&primary_keys=employee_id eq 1
You then need to let the previewer use this expression field and parse the URL from the HTML file.
You can access this part of the URL using window.location.search in the HTML file, this would contain “?subject=employee&primary_keys=employee%20id%20eq%201” in the example above.

Kind regards,
Leroy Witteveen

Userlevel 1
Badge +1

Thanks @Leroy Witteveen 
That is quite easy once you know it :-)