Layer7 API Management

  • 1.  How can I store a static body in the Service?

    Posted Aug 14, 2018 11:57 AM

    I have a service in my gateway that wil first route to another identy server to grab a Oauth token, and then will come back and rout again to another endpoint. On the last endpoint I need to attach token and a customized static body. How can I store a static body in the Service?

     

    So far I know that I can store a custom header in the route assertion, but in this scenario I need to know how to added the Authorization header, and also a custom static body, that is stored in the service it self. This body would not come from the initial request, it has to be added on.



  • 2.  Re: How can I store a static body in the Service?

    Posted Aug 14, 2018 05:37 PM

    Hi David,

     

    I just want to make sure I understand… If I understand correctly, your workflow looks something like this:

     

    Client > Gateway Service 1 > OAuth Token Issuer/IdP > Gateway Service 1 > Gateway Service 2 > Client

     

    So in other words, you have a client reaching to the Gateway, the Gateway reaches out to an identity provider, which then responds back to the Gateway, and the policy I suppose in your Gateway then routes to a second service on the Gateway - is that correct? And in that workflow you need the response on the first lap to be used as a request to the second service on the Gateway, is that also correct? It kind of sounds like you ultimately need to manipulate the data received in the response to forward the Authorization header while adding in a static body.

     

    If the above is a correct understanding, then I think you're going to want to use the Set Context Variable assertion as it allows you to create/set the content and save it all as a context variable which you can then use as a request source in the Route Via HTTP(S) assertion. You may also want to use the Manage Transport Properties/Headers assertion which will allow you to modify the headers if you need to too.

     

    I hope the above helps.



  • 3.  Re: How can I store a static body in the Service?

    Posted Aug 15, 2018 09:46 AM

    Hi Dustin,

     

    The flow looks a bit more like this:

    Client (Body1) > Gateway Service 1(Body2)> OAuth Token Issuer/IdP > Gateway Service 1(Body1+Token) > URL Endpoint> Client

     

    Here are samples of what the body would look like:

    Body1 =

    {
        "name": "Experian",
        "city": "somewhere",
        "state": "CA",
        "subcode": "#####",
        "street": "something",
        "zip": "azipcode",
        "phone": "########",
        "taxId": "######",
        "geo": true,
        "comments": "testing",
        "modelCode": "000224",
        "matchReliabilityCode": 83,
        "commercialScore": true,
        "fsrScore": true
    }

    Body2 = "Username, Password, Client ID, and Client Secret"

     

    1. The client will send a post request with (Body1) to the gateway service.

    2.The gateway service will then need initiate a call to IDP for token using (Body2) because the IdP s expecting that specific format of the body.

    3. When it gets the token and comes back to the gateway, the service will need to then route to the URL Endpoint using the OAuth token in the Authorization header and the body would have to be (Body1).

     

    - The Oauth Token IdP is looking for a "Username, Password, Client ID, and Client Secret" in the BODY.

    - The Url Endpoint is looking for the Oauth Token in the header, and the Body from the initial call to the gateway from the client (Body1).

     

    I hope this makes it more clear.

     

    Thanks for your help, I appreciate it!



  • 4.  Re: How can I store a static body in the Service?

    Posted Aug 24, 2018 07:01 PM

    Hi David,

     

    My apologies for the delay. Are you perhaps able to attach a copy of your policy workflow as you have it now? If there is any sensitive data, please look towards either cleaning it for the community or otherwise opening a support case so we can better review your environment on a WebEx.



  • 5.  Re: How can I store a static body in the Service?

    Broadcom Employee
    Posted Aug 27, 2018 01:51 AM

    Dear David,

    It seems the whole flow are processed in the same service policy, if true, the body1 is exactly in the client request.

    If you don't need any change on the body for incoming request, using default request message for the route via http to the URL Endpoint should be fine.

     

    Regards,

    Mark