Skip to content

Can you wrap an external API to convert the authentication method from OAUTH to IAM?

1

Our project strongly revolves around interacting with multiple external APIs which are protected using OAUTH2. The problem we are facing is that we interact with these APIs through many AWS services all of which require different setups to authenticate with this api.

For example STEP FUNCTIONS requires an EVENT BRIDGE CONNECTION to authenticate with external APIs whereas for LAMBDA we had to spin out own solution which would store the active auth token in a secret and refresh it every hour. All of this results in massive overhead, complexity and latency to simply communicate with an external api.

Now my question is if it would be possible to wrap the external APIs in a service like API GATEWAY which would handle the OAuth flow with the endpoint and itself use IAM. This way all of our internal services can simply make requests to this API Gateway using IAM and then the wrapper forwards the request with the OAuth token.

I played around with one solution, which is to have an API GATEWAY which forwards request to a STEP FUNCTION which then makes the external API request and returns the response. This worked for most things but I hit a headend because one of the endpoints is for file uploads, and STEP FUNCTIONS can't handle binary data.

1 Answer
0

Hey @Luis,

That is a good question and a tough problem to solve.

My team ran into a similar situation - we had more than one external service that we wanted to interact with, and so we made a single Lambda Function to act as an authorizer that acts as the entry point for (mostly) all our systems.

If you were to do this, you should be able to wrap your OAuth logic within a Lambda Function and authorize from your application wanting to hit your external API. Our motto tends to be if you can make it to the point where a Lambda Function comes into play, you can do pretty much anything 🥂

Documentation for this kind of thing can be found here.

Best of luck.

Chase

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.