Set and Pass Mulesoft client id and client secret in Proxy call | Community
Skip to main content
iamnjain
Community Advisor
Community Advisor
August 7, 2023
Solved

Set and Pass Mulesoft client id and client secret in Proxy call

  • August 7, 2023
  • 2 replies
  • 2361 views

Hello members,

 

We have a requirement, where we need to route FE - Mulesoft calls via AEM Dispatcher. So, we are using Dispatcher rewrites 301 Redirect to pass FE request (which is AEM SPA components only) to Mule system.

Now, we need to set Mule client id and client secret in incoming request and redirect to Mule system from Dispatcher.

 

Any pointers would be helpful and sample code example will be add on 🙂

 

Thanks!

cc: @aanchal-sikka @tanika02

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by yuriy_shestakov

Thanks @yuriy_shestakov for pointers.

So, I am trying to do that using rewrite rule to send request to Mule server. I need to set RequestHeader with client_id and client_secret.

 

How can I do that?

cc: @arunpatidar 


I've never done something like that. Only updated once request/response headers for the current request, not for remote.

Does it work with rewrite rules? I thought there must be a path on the same server, not a remote address. 

Or do you use some Apache module, like mod_proxy?

To update response headers I used this one:

 

<IfModule mod_headers.c> Header always set CLIENT_ID ${CLIENT_ID} </IfModule>

 

but it will update the headers that you send to the client. For the request it will be `RequestHeader set`, but I don't know if it works if you put it before RewriteRule.

 

Update: found a sample on Stackoverflow, you can try using <Location> directive.

<Location /api/mule/>
    Header set MULE_CLIENT_ID "clientId"
</Location>
...
RewriteRule ^/api/mule/(.*)$ https://mule.website/$1 [P]  

 

2 replies

viveksachdeva
Community Advisor
Community Advisor
August 8, 2023

301 redirects are cached by browsers, so these requests wouldn't even go to dispatcher once cached in browser. Any reason you are trying to do 301?

And I assume you want to pass client id and secret in headers?

yuriy_shestakov
Level 3
August 8, 2023

Hi @iamnjain ,

 

I would create that not on dispatcher but using a proxy servlet on AEM, which will receive all requests from your fronted, fulfill it with that secure data that you don't want your website visitors to see (clientId, password, etc.), send to Mule or whatever and return the response back to the website. It won't be processed on the dispatcher, but you can configure rewrites or caching for those requests if you wish.

viveksachdeva
Community Advisor
Community Advisor
August 8, 2023

I believe having AEM publisher as proxy is possible but not ideal as it is very expensive. We dont want to send traffic to publish that is unnecessary and can simply be handled by other system. Adobe IO could possible be one avenue you could check

iamnjain
Community Advisor
iamnjainCommunity AdvisorAuthor
Community Advisor
August 8, 2023

How can we do it on Adobe IO? @viveksachdeva