create_identity_source
async
¶
create_identity_source(
policy_store_id: PolicyStoreId,
configuration: Configuration,
*,
config_overrides: Optional[AsyncVerifiedPermissionsClientConfig] = None,
client_token: Optional[IdempotencyToken] = None,
principal_entity_type: Optional[PrincipalEntityType] = None,
) -> CreateIdentitySourceOutput
Adds an identity source to a policy store–an Amazon Cognito user pool or OpenID Connect (OIDC) identity provider (IdP).
After you create an identity source, you can use the identities provided by the IdP as proxies for the principal in authorization queries that use the IsAuthorizedWithToken or BatchIsAuthorizedWithToken API operations. These identities take the form of tokens that contain claims about the user, such as IDs, attributes and group memberships. Identity sources provide identity (ID) tokens and access tokens. Verified Permissions derives information about your user and session from token claims. Access tokens provide action context to your policies, and ID tokens provide principal Attributes.
Tokens from an identity source user continue to be usable until they expire. Token revocation and resource deletion have no effect on the validity of a token in your policy store
To reference a user from this identity source in your Cedar policies, refer to the following syntax examples.
-
Amazon Cognito user pool:
Namespace::[Entity type]::[User pool ID]|[user principal attribute], for exampleMyCorp::User::us-east-1_EXAMPLE|a1b2c3d4-5678-90ab-cdef-EXAMPLE11111. -
OpenID Connect (OIDC) provider:
Namespace::[Entity type]::[entityIdPrefix]|[user principal attribute], for exampleMyCorp::User::MyOIDCProvider|a1b2c3d4-5678-90ab-cdef-EXAMPLE22222.
Verified Permissions is eventually consistent . It can take a few seconds for a new or changed element to propagate through the service and be visible in the results of other Verified Permissions operations.
Parameters:
-
client_token(Optional[IdempotencyToken], default:None) –Specifies a unique, case-sensitive ID that you provide to ensure the idempotency of the request. This lets you safely retry the request without accidentally performing the same operation a second time. Passing the same value to a later call to an operation requires that you also pass the same value for all other parameters. We recommend that you use a UUID type of value..
If you don't provide this value, then Amazon Web Services generates a random one for you.
If you retry the operation with the same
ClientToken, but with different parameters, the retry fails with anConflictExceptionerror.Verified Permissions recognizes a
ClientTokenfor eight hours. After eight hours, the next request with the same parameters performs the operation again regardless of the value ofClientToken. -
policy_store_id(PolicyStoreId) –Specifies the ID of the policy store in which you want to store this identity source. Only policies and requests made using this policy store can reference identities from the identity provider configured in the new identity source.
To specify a policy store, use its ID or alias name. When using an alias name, prefix it with
policy-store-alias/. For example:-
ID:
PSEXAMPLEabcdefg111111 -
Alias name:
policy-store-alias/example-policy-store
To view aliases, use ListPolicyStoreAliases.
-
-
configuration(Configuration) –Specifies the details required to communicate with the identity provider (IdP) associated with this identity source.
-
principal_entity_type(Optional[PrincipalEntityType], default:None) –Specifies the namespace and data type of the principals generated for identities authenticated by the new identity source.
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this action.
-
InternalServerException–The request failed because of an internal error. Try your request again later
-
ThrottlingException–The request failed because it exceeded a throttling quota.
-
ValidationException–The request failed because one or more input parameters don't satisfy their constraint requirements. The output is provided as a list of fields and a reason for each field that isn't valid.
The possible reasons include the following:
-
UnrecognizedEntityType
The policy includes an entity type that isn't found in the schema.
-
UnrecognizedActionId
The policy includes an action id that isn't found in the schema.
-
InvalidActionApplication
The policy includes an action that, according to the schema, doesn't support the specified principal and resource.
-
UnexpectedType
The policy included an operand that isn't a valid type for the specified operation.
-
IncompatibleTypes
The types of elements included in a
set, or the types of expressions used in anif...then...elseclause aren't compatible in this context. -
MissingAttribute
The policy attempts to access a record or entity attribute that isn't specified in the schema. Test for the existence of the attribute first before attempting to access its value. For more information, see the has (presence of attribute test) operator in the Cedar Policy Language Guide.
-
UnsafeOptionalAttributeAccess
The policy attempts to access a record or entity attribute that is optional and isn't guaranteed to be present. Test for the existence of the attribute first before attempting to access its value. For more information, see the has (presence of attribute test) operator in the Cedar Policy Language Guide.
-
ImpossiblePolicy
Cedar has determined that a policy condition always evaluates to false. If the policy is always false, it can never apply to any query, and so it can never affect an authorization decision.
-
WrongNumberArguments
The policy references an extension type with the wrong number of arguments.
-
FunctionArgumentValidationError
Cedar couldn't parse the argument passed to an extension type. For example, a string that is to be parsed as an IPv4 address can contain only digits and the period character.
-
-
ConflictException–The request failed because another request to modify a resource occurred at the same time.
-
ResourceNotFoundException–The request failed because it references a resource that doesn't exist.
-
ServiceQuotaExceededException–The request failed because it would cause a service quota to be exceeded.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
To create an identity source
The following create-identity-source example creates an identity source that lets you reference identities stored in the specified Amazon Cognito user pool. Those identities are available in Verified Permissions as entities of type User.
>>> await client.create_identity_source(configuration={'cognitoUserPoolConfiguration': {'userPoolArn': 'arn:aws:cognito-idp:us-east-1:123456789012:userpool/us-east-1_1a2b3c4d5', 'clientIds': ['a1b2c3d4e5f6g7h8i9j0kalbmc']}}, policy_store_id='C7v5xMplfFH3i3e4Jrzb1a', principal_entity_type='User', client_token='a1b2c3d4-e5f6-a1b2-c3d4-TOKEN1111111')
Source code in docs_src/capo_verifiedpermissions/_services/async_verified_permissions.py
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 | |