LayerX Fintechäºæ¥é¨ï¼â»ï¼ã§ãã¬ããã³ã¹ã»ã³ã³ãã©ã¨ã³ã¸ãã¢ãªã³ã°ããã¦ãã é´æ¨ (@ken5scal )ã§ãã â»ä¸äºç©ç£ãã¸ã¿ã«ã»ã¢ã»ããããã¸ã¡ã³ãã«åºåãã¦ãã¾ãã
ä»åã¯ãAWS IAMããªã·ã¼ã®æ¡ä»¶ã«ããããForAllValuesãã®ä»æ§ã誤ã£ã¦ç解ãã¦ãããã¨ãããå®å ¨ã§ãªãã¢ã¯ã»ã¹å¶å¾¡ãå®è£ ãã¦ããã¨ããå 容ã§ããããåæ§ã®åéããããã¦ããæ¹ããããåèã«ãªãã°å¹¸ãã§ãã
ã¦ã¼ã¹ã±ã¼ã¹
AWS IAMã¦ã¼ã¶ã¼ãããã¼ã«ã® trust policy
ãã¦ã¼ã¶ã¼ã®ã¿ã°ã§å¶å¾¡ããã±ã¼ã¹ã§èãã¾ãã
å
·ä½çã«ã¯ããGroup Aãããã㯠Group Bãã«æå±ããä¸ã¤ãAdminã権éã®ããã¦ã¼ã¶ã¼ã®ã¿ãè¡ä½¿ã§ããå½¹å²ãAdminABRoleããããã¨ãã¾ãããã
ãã®å ´åãGroup
㨠Admin
ã®ã¿ã°ãåå¨ããä¸è¨ã®ãããªãã¿ã¼ã³ï¼â»ï¼ãèãããã¾ãã
â»å®å
¨ãªã«ãã¬ãã¸ã§ã¯ããã¾ããããæ¬ããã°ã®å
容ããçç¥ãã¾ãã
ã¦ã¼ã¶ã¼å | Groupã¿ã° | Adminã¿ã° | æ³å®æå |
---|---|---|---|
UserA | A | ã¿ã°ãã¼ãªã | â |
AdminA | A | true | ⯠|
UserB | B | ã¿ã°ãã¼ãªã | â |
AdminB | B | true | ⯠|
UserC | C | ã¿ã°ãã¼ãªã | â |
UserX | ã¿ã°ãã¼ãªã | ã¿ã°ãã¼ãªã | â |
UserY | ã¿ã°å¤ãªã | ã¿ã°å¤ãªã | â |
ã§ã¯ãæ©éãèªåãç¯ããééãããè¦ã¦ããã¾ãããã
ééã£ãããªã·ã¼ã®ä¾
# Bad example { "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::297323088823:root" }, "Action": "sts:AssumeRole", "Condition": { "ForAllValues:StringEquals": { "aws:PrincipalTag/Group": [ "A", "B" ], "aws:PrincipalTag/Admin": "true" } } } ] }
æ¹ãã¦ã§ãããä¸è¨ã§ã¯æå³ããã¢ã¯ã»ã¹å¶å¾¡ã«ãªãã¾ããã
å
·ä½çã«ã¯ãGroupã¿ã°ãã¼ã®ãªããAdminãä¿æã¦ã¼ã¶ã¼ããAdminãã¿ã°ãã¼ã®ãªãGroup A/Bæå±ã®ã¦ã¼ã¶ã¼ããããã¯ã¿ã°ãã¼ãå
¨ããªãã¦ã¼ã¶ã¼ï¼ä¾: UserXï¼ã¯è©ä¾¡ä¸ãtrueãã«ãªããAdminABRole
ã« assumeã§ãã¦ãã¾ãã¾ãã
é©åã«ã¢ã¯ã»ã¹å¶å¾¡ï¼Denyï¼ã§ãã対象ã¯ãUserCãUserYã®ã¿ã§ãã
ã¦ã¼ã¶ã¼å | Groupã¿ã° | Adminã¿ã° | æ³å®æå | å®éã®æå |
---|---|---|---|---|
UserA | A | ã¿ã°ãã¼ãªã | â | ⯠|
AdminA | A | true | ⯠| ⯠|
UserB | B | ã¿ã°ãã¼ãªã | â | ⯠|
AdminB | B | true | ⯠| ⯠|
UserC | C | ã¿ã°ãã¼ãªã | â | â |
UserX | ã¿ã°ãã¼ãªã | ã¿ã°ãã¼ãªã | â | ⯠|
UserY | ã¿ã°å¤ãªã | ã¿ã°å¤ãªã | â | â |
ã³ã£ãããã¡ããã¾ããã
æ£ããã¯æ¬¡ã®ããã«ãã¾ããå ã¨ã®éãã¯ãForAllValuesã修飾åãããã¾ããã
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Statement1", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::297323088823:root" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "aws:PrincipalTag/Group": [ "A", "B" ], "aws:PrincipalTag/Admin": [ "true" ] } } } ] }
Why?
ç´æ¥çãªåå ã¯ããForAllValuesãã®ä»æ§ã«ããã¾ãã
ä¸è¨ã®éãããForAllValuesãã¯è©ä¾¡å¯¾è±¡ã®ãaws:PrincipalTag/{tag-key}
ï¼ãå«ã¾ããContext Keysï¼ãåå¨ããªãå ´åããããã¯ããã®å¤ãnullãã¼ã¿ã»ããã¨å¤å®ãããå ´åãtrueãè¿ãã¾ããããã¥ã¡ã³ãã§ã¯ãNullæ¡ä»¶ä¿®é£¾åã®å©ç¨ããããã¦ç´¹ä»ããã¦ãã¾ãããæ¬ããã°ã®è¶£æ¨ã§ã¯ãªãã®ã§å²æãã¾ãã
It also returns true if there are no context keys in the request, or if the context key value resolves to a null dataset, such as an empty string.ï¼â»ï¼
Single-valued vs. multivalued context keys - AWS Identity and Access Management â»ã¿ã°å¤ã空ã«ããå ´åã¯ãã£ããfalseå¤å®ãããã®ã§ãno context keysã null datasetã«resolveãããvalueã®ãæ£ç¢ºãªæå³ãå³ãããã¦ãã¾ã...
ãã®ããã«èª¤è§£ããçç±ã¨ãã¦ã¯ãrequest contextã«ããContext Keyã®ãSingle-valued ãã¨ãmultivalued contextããééã£ã¦ç解ãã¦ããããã§ããå½åã¯åé¢ãã®ãã®ãåãæ¢ããè¤æ°ã®å¤ï¼valueï¼ãããã°ãmultivalued contextãã¨ãªãããããã£ã¦æ¬¡ã®ã«ã¼ã«ãé©ç¨ãããã¨æã£ã¦ãã¾ããã
Multivalued context keys require a condition set operator. Do not use condition set operators ForAllValues or ForAnyValue with single-valued context keys
Single-valued vs. multivalued context keys - AWS Identity and Access Management
ããããå®éã¯ããSingle-valued ãã¨ãmultivalued contextãã¯ãrequest contextã®ç¨®å¥ã§ããã
aws:PrincipalTag/{tag-key}
ã¯ãtagã®ãã¼ãã¨ã«è©ä¾¡ããããSingle-valued ãã§ããã
ãªããårequest contextã®ç¨®å¥ã¯æ¬¡ãã確èªã§ãã¾ãã
AWS global condition context keys - AWS Identity and Access Management
ã¡ãªã¿ã«
ãSingle-valued ãã¨ãmultivalued contextãã®éãã«ã¤ãã¦ã¯ããã¡ããã¡ãè¦åãã¦ãã¾ãããããã®ãã¼ã¸ã«è¡ãåã«ãã§ã«åéããã¦ã....
çµããã«
ä»åã¯ãForAllValues修飾åã®ä»æ§ééãã«ã¤ãã¦åãä¸ãã¾ããã ç´æ¥çãªå 容ã¯ä¸è¨ã®éãã§ãããæ ¹æ¬çã«ã¯ä»æ§ã®èª¤è§£ã§ããã ããããããã¯åä»ã§ãã ã³ãããªãã¾ã ãããï¼ï¼ï¼ã®ã§ããã誤解ã«ããæ§æãã¹ã«ã¤ãã¦ã¯ãä¸å®ã®ç¢ºçã§ããã£ã¦ãã¾ãããã§ãã ä¸å¿ãAWSã³ã³ã½ã¼ã«ä¸ã§ããã°IAM Access Analyzerãè¦åãã¦ããã¾ããããããIaCã¨ãã¦ãã§ãã¯ããããæãã¯ã·ã¹ãã ç£æ»çã«ããã«ã¯ã©ãããã°ãããã¯èããå¿ è¦ãããã¾ãã ãããã«ã¤ãã¦ã¯ä»å¾ã®ã¨ã³ããªã«ãæå¾ ãã ããã
絶è³æ¡ç¨ä¸ï¼
Fintech äºæ¥é¨(MDM)ã®ã³ã¼ãã¬ã¼ãã·ã¹ãã é¨ã§ã¯ãä¸è¨ã®ããã«é£ãã課é¡ãä¸åä¸å解ãã»ããã¦ããã ããã¡ã³ãã¼ãåéãã¦ãã¾ããæ¯éãä¸è¨ã https://twitter.com/ken5scalã®DMã§ã声ãããã ããï¼