Generic Lambda
-
My problem is that we have 4 applications and they all need a Populate JWT Lambda. The lambdas are excatly the same except for 1 hardcoded guid.
Right now I have copied the lambda into 4 and changed the id in each of them. It's not excatly best practise to have the same code repeated so I was wondering if there is a way to get around this fx by having a generic lamba that I can call from the other 4 lambdas, another solution could be if there is a way to get the application from the lambda (note that we do not use registrations) -
@mcad-pha Depending on your situation, there may be a few options.
If you assign the Lambda to the Access Token Populate lambda for the application, you can access the applicationId using jwt.applicationId. This would give you 1 function you could share across the applications if it works for you.
- If you assign the same lambda to the Id Token Populate lambda, you will get undefined.
If that does not work you may be able to use the fetch command in the Lambda. This would allow you to create a single function and have each of the applications call it, passing in the applicationId. This is only available in an Essentials or Enterprise plan.
- Reminder: If you have a paid plan, also remember you can access support through the Customer Account Portal as they may be quicker to respond.
-
I just took another look and jwt.aud may get you what you need in both instances as well.