Azure / api-management-policy-snippets

Re-usable examples of Azure API Management policies
MIT License
341 stars 155 forks source link

example: Switch from basic authentication to cookie based authentication #72

Closed KaiWalter closed 2 years ago

KaiWalter commented 2 years ago

An API level policy for a e.g. JAVA Spring based backend where after an initial request with basic authentication all subsequent requests are cookie based.

Shows application of custom cache value handling.

mikebudzynski commented 2 years ago

@adrianhall Could you please review Kai's PR?

KaiWalter commented 2 years ago

Valid point. So the use case is, that we have a Java Spring based back-end, which we hit with a high amount of GET/PUT/POST calls to make a data synchronization. Using continued basic auth had a negative impact on performance. Switching to cookie authentication relieved the backend of some of this stress and improved performance. Makes sense? And happy to apply any improvements / suggestions. I could test those anytime.

VitaliyKurokhtin commented 2 years ago
  1. Update cookie whenever set-cookie is returned by backend, not only when call was made without cookie. Backends often update cookies before they expire and it makes sense to refresh it in cache as well.
  2. Check if set-cookie header is present before storing it in cache
  3. Store in cache with duration from set-cookie header
KaiWalter commented 2 years ago

I pull back this PR for the moment.