I have an add-on which is a general page and supposed to be a single-page-application.
On SPA the user is meant to stay there for hours without having to navigate elsewhere.
The JWT that is generated by atlassian has expiry time in minutes. How am I supposed to refresh this token without forcing the user to refresh the page?
Although it doesn’t mention it in the documentation, Atlassian connect actually automatically refreshes the JWT token before it expires. I’ve created an issue for amending the documentation. Unfortunately I don’t have the link at hand
There is no javascript or api endpoint to retrieve the token. It is passed as a query string parameter (called jwt) whenever a module URL is loaded in the iframe.
@remie but when the user stays on the page (iframe) for 1 hour without refreshing or navigating, the JWT will have expired already. And that is the problem, I cannot send REST calls to my service with the same JWT token because it has expired.
I know, I have the same problem. The Atlassian JWT is designed to be used for calling the REST API from the host product. Atlassian will make sure that the JWT token remains valid as long as the user is signed in.
The general idea is that you provide your own session authentication (being JWT or http-only cookies) for the (subsequent) calls to your REST service. You can use the Atlassian JWT token for the initial communication with your own service to identify the user. After you have established the validity of the user, you can replace the Atlassian JWT with your own.
@remie ahh, that solution you describe is exactly the backup-solution I had in mind. Good to know there are others who have been in same situation and solved it this way.
Again thanks for the help, Remie. This issue can now be closed.
@jeevan is correct that Atlassian wouldn’t approve the extending exp solution. Such an approach exposes your add-on to replay attacks. The short time window is meant to prevent that kind of attack without burdening your add-on with the heavy burden of remembering jti claims as nonces.
I am using atlassian-connect-spring-boot on the backend and react on the client side. I handled it by adding a rest end point for heartbeat which returns a new fresh token. On the client side before the expiration of token I trigger the /heartbeat and refresh the token.
I have a global page as react app. And I am running in the issue with invalid jwt tokens. Of course I can handle this by myself and create an own authentication method with own jwts. But in so REST services I need to use the Confluence-API. This doesn’t work without a valid Atlassian token?
Can you give me some advises to handle such a scenario?