Prevents the user from signing in with the specified external (SAML or social) identity provider (IdP). If the user that you want to deactivate is a Amazon Cognito user pools native username + password user, they can't use their password to sign in. If the user to deactivate is a linked external IdP user, any link between that user and an existing user is removed. When the external user signs in again, and the user is no longer attached to the previously linked DestinationUser, the user must create a new user account.
The value of ProviderName must match the name of a user pool IdP.
To deactivate a local user, set ProviderName to Cognito and the ProviderAttributeName to Cognito_Subject. The ProviderAttributeValue must be user's local username.
The ProviderAttributeName must always be Cognito_Subject for social IdPs. The ProviderAttributeValue must always be the exact subject that was used when the user was originally linked as a source user.
For de-linking a SAML identity, there are two scenarios. If the linked identity has not yet been used to sign in, the ProviderAttributeName and ProviderAttributeValue must be the same values that were used for the SourceUser when the identities were originally linked using AdminLinkProviderForUser call. This is also true if the linking was done with ProviderAttributeName set to Cognito_Subject. If the user has already signed in, the ProviderAttributeName must be Cognito_Subject and ProviderAttributeValue must be the NameID from their SAML assertion.
Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.
Learn more
Parameters:
-
user_pool_id
(StringType)
–
The ID of the user pool where you want to delete the user's linked identities.
-
user
(ProviderUserIdentifierType)
–
The user profile that you want to delete a linked identity from.
Raises:
-
AliasExistsException
–
This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias.
-
InternalErrorException
–
This exception is thrown when Amazon Cognito encounters an internal error.
-
InvalidParameterException
–
This exception is thrown when the Amazon Cognito service encounters an invalid parameter.
-
NotAuthorizedException
–
This exception is thrown when a user isn't authorized.
-
OperationNotEnabledException
–
This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.
-
ResourceNotFoundException
–
This exception is thrown when the Amazon Cognito service can't find the requested resource.
-
TooManyRequestsException
–
This exception is thrown when the user has made too many requests for a given operation.
-
UserNotFoundException
–
This exception is thrown when a user isn't found.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_cognito_identity_provider/_services/cognito_identity_provider.py
| def admin_disable_provider_for_user(
self,
user_pool_id: "capo_cognito_identity_provider.types.string_type.StringType",
user: "capo_cognito_identity_provider.types.provider_user_identifier_type.ProviderUserIdentifierType",
*,
config_overrides: Optional[CognitoIdentityProviderClientConfig] = None,
) -> "capo_cognito_identity_provider.types.admin_disable_provider_for_user_response.AdminDisableProviderForUserResponse":
"""<p>Prevents the user from signing in with the specified external (SAML or social) identity provider (IdP). If the user that you want to deactivate is a Amazon Cognito user pools native username + password user, they can't use their password to sign in. If the user to deactivate is a linked external IdP user, any link between that user and an existing user is removed. When the external user signs in again, and the user is no longer attached to the previously linked <code>DestinationUser</code>, the user must create a new user account.</p> <p>The value of <code>ProviderName</code> must match the name of a user pool IdP.</p> <p>To deactivate a local user, set <code>ProviderName</code> to <code>Cognito</code> and the <code>ProviderAttributeName</code> to <code>Cognito_Subject</code>. The <code>ProviderAttributeValue</code> must be user's local username.</p> <p>The <code>ProviderAttributeName</code> must always be <code>Cognito_Subject</code> for social IdPs. The <code>ProviderAttributeValue</code> must always be the exact subject that was used when the user was originally linked as a source user.</p> <p>For de-linking a SAML identity, there are two scenarios. If the linked identity has not yet been used to sign in, the <code>ProviderAttributeName</code> and <code>ProviderAttributeValue</code> must be the same values that were used for the <code>SourceUser</code> when the identities were originally linked using <code> AdminLinkProviderForUser</code> call. This is also true if the linking was done with <code>ProviderAttributeName</code> set to <code>Cognito_Subject</code>. If the user has already signed in, the <code>ProviderAttributeName</code> must be <code>Cognito_Subject</code> and <code>ProviderAttributeValue</code> must be the <code>NameID</code> from their SAML assertion.</p> <note> <p>Amazon Cognito evaluates Identity and Access Management (IAM) policies in requests for this API operation. For this operation, you must use IAM credentials to authorize requests, and you must grant yourself the corresponding IAM permission in a policy.</p> <p class="title"> <b>Learn more</b> </p> <ul> <li> <p> <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html">Signing Amazon Web Services API Requests</a> </p> </li> <li> <p> <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pools-API-operations.html">Using the Amazon Cognito user pools API and user pool endpoints</a> </p> </li> </ul> </note>
Args:
user_pool_id: <p>The ID of the user pool where you want to delete the user's linked identities.</p>
user: <p>The user profile that you want to delete a linked identity from.</p>
Raises:
capo_cognito_identity_provider.errors.alias_exists_exception.AliasExistsException: <p>This exception is thrown when a user tries to confirm the account with an email address or phone number that has already been supplied as an alias for a different user profile. This exception indicates that an account with this email address or phone already exists in a user pool that you've configured to use email address or phone number as a sign-in alias.</p>
capo_cognito_identity_provider.errors.internal_error_exception.InternalErrorException: <p>This exception is thrown when Amazon Cognito encounters an internal error.</p>
capo_cognito_identity_provider.errors.invalid_parameter_exception.InvalidParameterException: <p>This exception is thrown when the Amazon Cognito service encounters an invalid parameter.</p>
capo_cognito_identity_provider.errors.not_authorized_exception.NotAuthorizedException: <p>This exception is thrown when a user isn't authorized.</p>
capo_cognito_identity_provider.errors.operation_not_enabled_exception.OperationNotEnabledException: <p>This exception is thrown when an operation is not available in the current region or for the current user pool configuration. This can occur when attempting to perform operations that are not supported in secondary replica regions.</p>
capo_cognito_identity_provider.errors.resource_not_found_exception.ResourceNotFoundException: <p>This exception is thrown when the Amazon Cognito service can't find the requested resource.</p>
capo_cognito_identity_provider.errors.too_many_requests_exception.TooManyRequestsException: <p>This exception is thrown when the user has made too many requests for a given operation.</p>
capo_cognito_identity_provider.errors.user_not_found_exception.UserNotFoundException: <p>This exception is thrown when a user isn't found.</p>
capo_cognito_identity_provider.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
def _handler(
req: "OperationRequest[capo_cognito_identity_provider.types.admin_disable_provider_for_user_request.AdminDisableProviderForUserRequest]",
) -> OperationResponse[
"capo_cognito_identity_provider.types.admin_disable_provider_for_user_response.AdminDisableProviderForUserResponse"
]:
import capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.admin_disable_provider_for_user
output, http_response = (
capo_cognito_identity_provider._operations.aws_cognito_identity_provider_service.admin_disable_provider_for_user.admin_disable_provider_for_user(
req.options, req.input
)
)
return OperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("AdminDisableProviderForUser")
)
input_: capo_cognito_identity_provider.types.admin_disable_provider_for_user_request.AdminDisableProviderForUserRequest = {
"user_pool_id": user_pool_id,
"user": user,
}
response = execute_pipeline(
OperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
response.response.close()
return response.output
|