
AWS grants access to its services based on the policies assigned to the users. There are identity-based policies (such as for users) and resource based policies (such as s3 bucket policies)
The effective permission for a user is computed based on:
- In-line and directly attached policies to the user.
- The policies of the Groups the user belongs to.
- Permission boundary policy attached to the user.
- Service control policy (SCP) attached to the account (or Organizational Unit, OU) if the user AWS account is part of an AWS organization.
- The Resource control policies (RCP) attached to the Organization Unit.
- The policies attached directly to resources (such as S3 bucket policies).
Here is a program (API link below) that computes the effective user policy based on above criteria. The output is a json response.
Please note below important point:
- “Conditions” in policies are not included.
- Session policies are not included in evaluation.
End point to send request: https://api.ramana.tech/aws/user-effective-permissions
Http method: POST
Content-type: application/json
A sample json request input:
{
"queryUser":"test_user", //For whom you want effective policy
"region":"us-east-1",
"accessId":"aaaaaaaaaaaa",
"secretKey":"bbbbbbbbbbbbbbb"
}
In the above sample request body, the accessId and secretKey are for a user (the ‘privileged user’) who has required policy attached. Sample policy given below. (It is not for the ‘queryUser’).
- Attach policy with required permissions, to the ‘privileged user’ (A sample policy given below).
- In addition to above policy (attached to the privileged user), if your AWS account is member of an organization:
- Your org admin (management account) should attach a policy under ‘Delegated Administrator’ section of “Organizations (AWS console page)” -> Settings. The ‘Delegated policy’. Sample given below.
Also note:
-
- The credentials mentioned in your API request are not stored/logged anywhere.
- It can take several minutes to compute the response depending on number of policies.
Let me know your comments!!!!