How to add & use array values in claims of Cognito's IdToken in AWS IAM policies?

0

Hello, I have a use-case where I need to add custom attributes to AWS Cognito user-pool with array values, e.g.: {"floors": ["1","3", "7"]}.

Then, I want to define a policy that allow access to a resource only if the PrincipalTag ("floors") has an element value ("3") that match the resource tag ("floor"="3").

Can this be implemented via AWS IAM Policy? How?

Thank you.

1개 답변
0

Cognito only supports string attributes, but you can mimic a multi-value attribute with your own delimiter between and around the values. Take this example using : to separate your floors values:

{"floors": ":1:3:7:"}

Then your aws:PrincipalTag/tag-key check can use StringLike in a Condition with leading *: and trailing :* wildcards to match the floor. This assumes your floor values don't contain : and they aren't user-defined input that would allow someone to inject their own : character.

"Condition": {
  "StringLike": { "aws:PrincipalTag/floor": "*:3:*" }
},
profile pictureAWS
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠