Granting permissions to create temporary security credentials
By default, IAM users do not have permission to create temporary security credentials for Amazon STS federated user sessions and roles. You must use a policy to provide your users with these permissions. Although you can grant permissions directly to a user, we strongly recommend that you grant permissions to a group. This makes management of the permissions much easier. When someone no longer needs to perform the tasks associated with the permissions, you simply remove them from the group. If someone else needs to perform that task, add them to the group to grant the permissions.
To grant an IAM group permission to create temporary security credentials for Amazon STS federated user sessions or roles, you attach a policy that grants one or more of the following privileges:
-
For OIDC and SAML federated principals to access an IAM role, grant access to Amazon STS
AssumeRole. -
For Amazon STS federated users that don't need a role, grant access to Amazon STS
GetFederationToken. -
For principals that need to scope down the permissions of a session they already hold, grant access to Amazon STS
GetScopedCredentials.
For more information about the differences between the AssumeRole and
GetFederationToken API operations, see Request temporary security credentials.
IAM users can also call GetSessionToken to create temporary security credentials. No
permissions are required for a user to call GetSessionToken. The purpose of this
operation is to authenticate the user using MFA. You cannot use policies to control
authentication. This means that you cannot prevent IAM users from calling
GetSessionToken to create temporary credentials.
Example policy that grants permission to assume a role
The following example policy grants permission to call AssumeRole for the
UpdateApp role in Amazon Web Services account 123123123123. When
AssumeRole is used, the user (or application) that creates the security
credentials on behalf of a federated user cannot delegate any permissions that are not already
specified in the role permission policy.
Example policy that grants permission to create temporary security credentials for a federated user
The following example policy grants permission to access
GetFederationToken.
When you give IAM users permission to create temporary security credentials for Amazon STS
federated users with GetFederationToken, be aware that this permits those users
to delegate their own permissions. For more information about delegating permissions across
IAM users and Amazon Web Services accounts, see Examples of policies for delegating access. For more information about controlling
permissions in temporary security credentials, see Permissions for temporary security credentials.
Example policy that grants a user limited permission to create temporary security credentials for federated users
When you let an IAM user call GetFederationToken, it is a best practice to
restrict the permissions that the IAM user can delegate. For example, the following policy
shows how to let an IAM user create temporary security credentials only for Amazon STS federated
users whose names start with Manager.
Unlike AssumeRole, GetScopedCredentials does not require a trust
policy on a target role, because there is no target role. The caller is scoping down its own
existing credentials. The only permission required is the sts:GetScopedCredentials
action on the caller's own identity-based policy or an identity-based policy attached to the
role whose session the caller holds.
Example policy that grants permission to create scoped down credentials from an existing session
The following sample policy grants permission to call GetScopedCredentials.
Because GetScopedCredentials operates on the caller's own session (there is no
separate resource ARN), the resource is specified as "*".