cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic configuration and reuse of policies

gregorw
Active Contributor
0 Kudos

Hello SAP API Management Experts,

in the great Blog Series JSON Web Tokens (JWT) verification using SAP Cloud Platform API Management divya.mary describes in great detail the setup of some quite complex policies that allow the verification of an JWT that was created by an external Identity Provider. What I ask myself: How can I scale this approach to multiple APIs.

  1. Is there a way to reuse the defined policy?
  2. Can the policy be parameterised so I can export from the dev tenant and import to production without manual adjustments?

Looking forward for your input.

Best regards
Gregor

Accepted Solutions (1)

Accepted Solutions (1)

ElijahM
Advisor
Advisor

Hi Gregor,

In general there are 2 simple answers, and many complex answers to your query above.

1) Re-use of policies - the policy template concept was designed for the re-use of simple and complex policy configurations alike. If you are not familiar with this you can read more here: https://blogs.sap.com/2017/08/28/policy-management-made-easy-with-templates-in-sap-api-management/

Within the Policy template creation you can take all or a selection of policies applied to an API Proxy and create a re-usable template which can be applied in part or whole to future API Proxies. In the case that you are utilizing a group of API Proxies which all need to leverage SSO via JWT token handling for example, this would be a great use case of templatizing the above and applying to the API proxy group.

2) Parameterization can be done in a number of ways, the simplest usually being to generate variables to be called in the processing, though this will be specific to the scenario being implemented. For example in each account you could utilize a Key-Value Map with a list of common URIs associated to a common variable name. In which case the policy requests pointing to URIs instead of calling static URIs would instead call the variable name and as you transport between environment you would not need to change the policy, while still having it call the distinct URIs of the system. A simple example of KVM shown here https://blogs.sap.com/2018/09/24/working-with-key-value-maps-using-sap-cloud-platform-api-management...

Where it is less simple is around less common scenarios, if you wanted to have a centrally managed and easily updatable Template for example, this would be difficult with the existing template policy as you would need to re-apply any changes to all API proxies. You could for example possibly leverage a service callout to an API Proxy with a set of API Policies and then only make changes to that Proxy (which would automatically be propagated to all API Proxies calling that API).

Or for parameterization you could leverage the Custom Attribute concept to apply arbitrary data along side a (JWT) token - https://help.sap.com/viewer/66d066d903c2473f81ec33acfe2ccdb4/Cloud/en-US/90a5a6d2a75f4426964ec85c49f... ; or use ExtractVariable policy to pull some information and populate a variable during execution. I don't want to go down a rabbithole but I wanted to highlight the flexibility (and challenge of this flexibility) of the API management service.

I hope that I did not go too far off a tangent of the source of your question and was able to address the heart of your ask.

Regards,
Elijah

gregorw
Active Contributor
0 Kudos

Thank you Elijah. Your input is very appreciated. Need to dig deeper there now.

gregorw
Active Contributor
0 Kudos

Hi Elijah,

hope that you can provide feedback to my comment that I've posted in the blogpost regarding policy templates.

Thanks.

Best regards
Gregor

ElijahM
Advisor
Advisor

Hi Gregor,

I see that Shruthi has replied - I believe she has said everything I would have and more 🙂

Regards,
Elijah

Answers (0)