Auth tokens with Fetch API

aidos
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 21, 2021

I am in the process of migrating from an on-prem Confluence installation to a Atlassian Cloud instance and one of the things I need to do is rewrite a custom macro that we have using Forge.

I have a lambda running in an AWS VPC that connects to a service inside my corporate network (via VPN) that I will need to now expose to the public internet and I want to make sure that this is secured so only my Confluence Cloud instance can retrieve data from it.

I could use an AWS API Gateway Header security token, but this feels relatively insecure. What I would like to do is instead use a custom lambda to perform authorization for any calls to my lambda endpoint.

Using the fetch API as part of Forge, is it possible to pass the OAuth bearer token that the user is using to authenticate to the Atlassian services along with my request to my external API endpoint?

Originally I was going to just craft a HMAC for my request (containing the payload, as well as the confluence cloud id) but it looks like the crypto library shim in Forge is not complete as the 'forge tunnel' command crashes when I attempt to use the crypto.

Using this approach means that way my custom authorization lambda could validate that the token is from my Atlassian instance and return the content, returning a 403 for all other requests. Alternatively, is there a better way to be able to secure my external API call so only users in my Atlassian cloud account can access it?

 

1 answer

0 votes
Laura Campbell [Seibert Media]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 24, 2022

Hello @aidos 

You'll probably get more help for your question by posting it on https://community.developer.atlassian.com/

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events