We are migrating our infrastructure into AWS. We are developing a backend layer as Lambda functions and will host it behind API Gateway. We are using client credentials flow and authenticating the client using client id - secret. After we send a token request to Oauth in Cognito it returns an access token and we are using this token to access REST Services hosted by API Gateway.
So, we need to differentiate the owner of the request for two purposes; -First, we want to audit inputs and outputs along with the name of the organization (one organization might have different app clients) -Second, we might need to have different behaviour in the lambda functions according to the name of the organizations. We want to use client credential flow to make accessing APIs easier.
I thought I can add custom fields and use the fields in the JWT access token, however, this answer says it is impossible. -> https://stackoverflow.com/a/62382001
Is there any suggestion to differentiate users in Lambda functions according to the information we can add in cognito side. (I am planning this field will belong to app-client) Or is there any way to differentiate users in API Gateway and send the information to Lambda functions?
If there is any non-clear part of my questions please write me that and I can clarify. Thanks in advance.
Ihsan