reverse lookup of subscription key

Wayne Theron 1 Reputation point
2021-03-04T07:35:51.53+00:00

I need to access the group information of an api caller who has a subscription key for api management. I would like to be able to modify the header through policies and add the group info to the header. my backend api will use this information for enforcing row level security on the data being queried.

all I have when the caller makes the request is their subscription key so I would need to do the lookup and insert through group policies. is there a way I can access group info for the caller through api management policies?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,751 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Wayne Theron 1 Reputation point
    2021-03-04T09:17:27.34+00:00

    it seems to me that the only way to achieve this is via portal delegation where we can take ownership of login and subscribe where we can then access the information programmatically. I don't see any api management sdk or feature that allows programmatic access to user, groups and subscription keys.

    0 comments No comments

  2. ChaitanyaNaykodi-MSFT 22,776 Reputation points Microsoft Employee
    2021-03-08T18:03:04.453+00:00

    Hello @Wayne Theron , apologies for the delay. I think the requirement can be satisfied using the Context variable. You can get the association of an user to a group using context.User.Groups then use the Set HTTP header policy to modify the header. To programmatically access the user, groups and subscription please go through this REST API for API management.
    You can refer to this question here for implementation. Please let me know if there are any additional concerns. Thank you!

    0 comments No comments