Muhammad Ali
10/16/2021, 3:19 AMChad (cysense)
10/16/2021, 4:23 AMMuhammad Ali
10/16/2021, 5:20 AMAWS_IAM
work for my use-case. see these 2 threads for details
1. https://serverless-stack.slack.com/archives/C01HQQVC8TH/p1634323975440100
2. https://serverless-stack.slack.com/archives/C01HQQVC8TH/p1634327676443000Chad (cysense)
10/16/2021, 5:25 AMMuhammad Ali
10/16/2021, 4:00 PMMuhammad Ali
10/16/2021, 4:16 PMclaimsToAddOrOverride
but i am unable to access/view it?
3. When user authenticate, return department id as encrypted value which can be used as request header in subsequent request. I haven't explored this option yet. But for this i need to understand what response is returned when a user authenticates and how to extract value out of it. i have been using npx aws-api-gateway-cli-test
which abstracts everything, so would have to look into that.Michael Clifford
10/16/2021, 6:54 PMChad (cysense)
10/17/2021, 3:30 AMsst.ApiAuthorizationType.JWT
instead of IAM
. You would use IAM if you want your users to access other AWS resources. @Michael Clifford's repo shows an example of setting this all up how you want.
The second point on your 'extra' claims. The easiest solution would be to use your point 1 (maintain a mapping in the DB). This is what we have done and it gives us greater flexibility than doing it with cognito custom attributes. I can't imagine this would be much more expensive than what you are trying to do already. The trade off is one extra DDB read vs running a preTokenGeneration
lambda trigger. I haven't done the math but I can imagine it is close.
If you really don't want to a table for the mapping then you could look at using custom attributes instead. The biggest gotcha with custom attributes, is that you need to give your clients permission to read/write to custom attributes. You can have a look here on how to setup custom attributes https://bobbyhadz.com/blog/aws-cdk-cognito-user-pool-example#cognito-user-pool-client-in-aws-cdk---example.
So in summary:
1. Use CognitoUserPools as the auth mechanism. sst.ApiAuthorizationType.JWT
in SST
2. Use either a DB mapping or custom cognito attributes instead of a lambda trigger to handle granular user access in your appMichael Clifford
10/17/2021, 3:36 AMChad (cysense)
10/17/2021, 3:49 AMSimon Reilly
10/17/2021, 8:27 AMOmi Chowdhury
10/17/2021, 4:17 PMMuhammad Ali
10/18/2021, 3:05 PM