Hi Ivy Team, Is there a way to get the JSESSIONID (or the whole cookie itself) of the logged in user ? I want to build a rest method which is authenticating the user. I need to return the cookie, so that next requests are authenticated BR, Yordan |
If setting up a BASIC_AUTH header on client side is the main issues I think it should be possible to solve this in an additional Currently auth and session handling is done in : The request filter comes with a priority (in this case: 1'000). Therefore, it should be possible to provide an additional request filter that can change the request just before the default filter is executed. Your custom filter could compensate the inabilities of the real client > transform form params into http_basic auth headers. To setup your custom filter as general extension for the ivyEngine REST stack you have to add the ...just an idea: I did not check it with an example. PS: be aware that big improvements from 7.4 REST stack have been ported back to the 7.0 LTS train recently. So ensure that you work with the latest hotfix version to benefit of the extension capabilities mentioned here. |
Hi Reguel, I was able to add Authorization Basic header before ApplicationSessionRequestFilter. In result, the session of the user was changed based on this header. However, the returned cookie form this request, is still not valid for the next calls ... ) the second call is authenticated as Developer) I assume that this is a bug. Here how you can reproduce it:
html:
BR, Yordan Hi Yordan. Glad to hear on your success on providing a custom request filter to transform headers. Currently I do not have the time do drive further analysis why the session is not overtaken. But I'm confident that you can find the cause quickly by using a class decompiler + debugger to analyse the execution of our ApplicationSessionRequestFilter. The tracing on which terms the existing session are overtaken should be easy to see in there. If nothing works. You could try to handle the issue in a global tomcat Valve : which is in charge not only for the rest stack, but for the whole webserver. Some documentation to start with valves can be found here : https://developer.axonivy.com/doc/latest/engine-guide/integration/web-application-firewall.html |
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 30.09.2019 at 03:58
Seen: 6,757 times
Last updated: 11.10.2019 at 08:05
If the client is in the browser the JSESSIONID works for both the web and the rest stack. But this is transparent and you have nothing to configure. Generally it is not possible to get the JSESSION cookie, this would be a security risk. But that I can give you a concrete answer you have to explane exactly what is your usecase...
If you design the API to only allow normal users : the login will automatically be done based on the HTTP_BASIC auth headers. What value do you have if you can enforce to send it as POST and handle auth on your own?
Hi Reguel,
The client application (browser) cannot be modified to send basic auth header. it sends user and password and It works only with cookie after that.
And the problem I have with Axon.Ivy is that if a REST method has @PermitAll it automatically creates a session and the returns a cookie for this session (and not for the user which I`m trying to login)
Basically, the question is -> How to do a REST method which is login a user and returns back cookie for for it
BR, Yordan