How to Share 1 JsonWebToken for 2 app to use

35 Views Asked by At

So I have a problem I have 2 application which are deployed on the same website with different ports, one is a Login application and one is a HRIS System.

My problem is that when my login app created the token and redirect to my hris system the hris app is still asking for credentials.

So I checked in the web console->application->local storage there's a token in my login app but when I go to the HRIS app its not there ?

Login app web console enter image description here

HRIS app web console enter image description here

Thanks in Advance..

2

There are 2 best solutions below

0
arespati On BEST ANSWER

Same website with different ports means different applications and resource sharing between apps is strictly forbidden.

Well, there's a large discussion about sharing resource over different apps, but sharing credential is bad practice, you should try read OAuth for alternative strategy.

login > success > save to localstorage > redirect to HRIS. I assume this is your current workflow? You can pass it as encrypted token as you redirecting to HRIS app. Decrypt it there and save it again to HRIS local storage.

0
31piy On

That's because browser's local storage is specific to one hostname and port, and isn't shared with others.

I see that you've it on some host and port number 85. So it won't even be shared with the same host on port number 82. That's how it works.