In my first post of this series, I talked about subscriptions. The next post in this series is about cookie sharing in APEX, I hope you enjoy it.
Apex SSO by Cookie sharing
In the spirit of the previous post, this post will also be one that comes in handy when running multiple applications in the same workspace. When running multiple applications in the same workspace, it’s possible to share the authentication across multiple applications so you don’t have to login every time you switch applications. The only problem is that the feature is tucked away pretty good in the authentication scheme settings.
First we will Create 2 standard Applications
Now we will create a simple page with a link to a page in the other application, to test if our setup works.
If we would click the link now we would be redirected to the login page of the other application since, we’re not yet authenticated.
What we need to do now is set up our authentication, to keep it simple I will make a hardcoded function where the process checks for username and password admin. But feel free to use your own custom login procedure.
Now for the important part, scroll down in the authentication scheme until you see a block called “Session Cookie Attributes”
In the cookie name field, you can set a name for your cookie, the important thing for this to work is that the name is the same in both applications, you also have the option here to define extra settings for your cookie. Whether it should be secure or not and the cookie path and domain.
In the second application create the same authentication scheme as a copy of an existing authentication scheme. You can subscribe the authentication scheme to the first application.
For more information about subscription you can look at my first post.
If we log in to one of our applications now, we should be able to switch applications by clicking on the link we have created