I am working on back-porting a Connect app to P2 and have some questions/concerns regarding datacenter compatibility.
Some of my Connect code relies on the security context received in the installed lifecycle event, namely host client_key and the shared secret. To make things work the same way in P2, I have been thinking of creating a similar security context when the P2 app is installed and save it in the DB.
If I create a component that installs/uninstalls the security context and implements
DisposableBean, can I be sure that the two implemented methods run only once on plugin install/enable or uninstall/disable in a clustered environment?
What value to use for client key? I am looking for a constant value that is the same for all nodes in any deployment scenario (normal and datacenter). I am contemplating on whether it is safe to use Server ID as an identifier for an installation, however, this article on “What is Server ID?” says:
The Server ID is the same for all servers in a cluster (Confluence only)
If I understand this correctly, it is not safe to use Server ID as “client key” in P2 because different Jira nodes in the same datacenter installation could potentially have different Server IDs.
Another option might be to simply generate a client key value or use a hard-coded constant. This implies that there must always be just one security context record in the database (per Server/datacenter installation). This would be required because there is no data in the security context that links it to the Jira Server/datacenter installation that would allow inferring the security context.
Does anyone have an opinion on this or knows a better value to use that works in all deployment scenarios?
Hope my ideas and concerns are clear. Otherwise, I am happy to clarify. Appreciate any input, thanks!