Hello, this is a question related to making authenticated calls from JCMA migration job to a linked Confluence instance.
Scenario: In a Jira Server app, there is a a class that implements CloudMigrationListenerV1
interface, to provide Jira Server to Cloud migration capabilities. This is also the starting point for app’s migration logic. From there, I tried unsuccessfully to fetch data from connected Confluence instance (via HTTP request created using ApplicationLinkRequestFactory. createRequest()
method). The Confluence server is connected to Jira by Application Link, the link is working fine in other parts of the application and Jira settings says the link is connected.
It appears that when JCMA runs my custom migration logic, it is executed outside of calling user’s context. As a result, every call from the class that implements CloudMigrationListenerV1
interface to connected Confluence instance is not authenticated and it goes as anonymous, which results in HTTP 403
status. I expected a call made on behalf of the user that initiated JCMA-assisted migration.
Under debugger, I checked the return value of ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
and com.atlassian.sal.api.user.UserManager.getRemoteUser()
from a class that implements CloudMigrationListenerV1 and in both cases the returned value is null. I also get this in Jira log when JCMA runs the migration:
`[c.a.a.core.auth.ApplicationLinkRequestFactoryFactoryImpl] No current user context. Outgoing requests will be anonymous.
Once again, both authenticating and calling connected Confluence instance are working fine in other parts of application. I am not creating any new threads either.
Question: cloud you share any information how to call a connected app from a class that implements CloudMigrationListenerV1
?