CognitoIdentityProvider / Client / set_risk_configuration
set_risk_configuration#
- CognitoIdentityProvider.Client.set_risk_configuration(**kwargs)#
Configures threat protection for a user pool or app client. Sets configuration for the following.
Responses to risks with adaptive authentication
Responses to vulnerable passwords with compromised-credentials detection
Notifications to users who have had risky activity detected
IP-address denylist and allowlist
To set the risk configuration for the user pool to defaults, send this request with only the
UserPoolId
parameter. To reset the threat protection settings of an app client to be inherited from the user pool, sendUserPoolId
andClientId
parameters only. To change threat protection to audit-only or off, update the value ofUserPoolAddOns
in anUpdateUserPool
request. To activate this setting, your user pool must be on the Plus tier.See also: AWS API Documentation
Request Syntax
response = client.set_risk_configuration( UserPoolId='string', ClientId='string', CompromisedCredentialsRiskConfiguration={ 'EventFilter': [ 'SIGN_IN'|'PASSWORD_CHANGE'|'SIGN_UP', ], 'Actions': { 'EventAction': 'BLOCK'|'NO_ACTION' } }, AccountTakeoverRiskConfiguration={ 'NotifyConfiguration': { 'From': 'string', 'ReplyTo': 'string', 'SourceArn': 'string', 'BlockEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' }, 'NoActionEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' }, 'MfaEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' } }, 'Actions': { 'LowAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' }, 'MediumAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' }, 'HighAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' } } }, RiskExceptionConfiguration={ 'BlockedIPRangeList': [ 'string', ], 'SkippedIPRangeList': [ 'string', ] } )
- Parameters:
UserPoolId (string) –
[REQUIRED]
The ID of the user pool where you want to set a risk configuration. If you include
UserPoolId
in your request, don’t includeClientId
. When the client ID is null, the same risk configuration is applied to all the clients in the userPool. When you include bothClientId
andUserPoolId
, Amazon Cognito maps the configuration to the app client only.ClientId (string) –
The ID of the app client where you want to set a risk configuration. If
ClientId
is null, then the risk configuration is mapped toUserPoolId
. When the client ID is null, the same risk configuration is applied to all the clients in the userPool.When you include a
ClientId
parameter, Amazon Cognito maps the configuration to the app client. When you include bothClientId
andUserPoolId
, Amazon Cognito maps the configuration to the app client only.CompromisedCredentialsRiskConfiguration (dict) –
The configuration of automated reactions to detected compromised credentials. Includes settings for blocking future sign-in requests and for the types of password-submission events you want to monitor.
EventFilter (list) –
Settings for the sign-in activity where you want to configure compromised-credentials actions. Defaults to all events.
(string) –
Actions (dict) – [REQUIRED]
Settings for the actions that you want your user pool to take when Amazon Cognito detects compromised credentials.
EventAction (string) – [REQUIRED]
The action that Amazon Cognito takes when it detects compromised credentials.
AccountTakeoverRiskConfiguration (dict) –
The settings for automated responses and notification templates for adaptive authentication with threat protection.
NotifyConfiguration (dict) –
The settings for composing and sending an email message when threat protection assesses a risk level with adaptive authentication. When you choose to notify users in
AccountTakeoverRiskConfiguration
, Amazon Cognito sends an email message using the method and template that you set with this data type.From (string) –
The email address that sends the email message. The address must be either individually verified with Amazon Simple Email Service, or from a domain that has been verified with Amazon SES.
ReplyTo (string) –
The reply-to email address of an email template.
SourceArn (string) – [REQUIRED]
The Amazon Resource Name (ARN) of the identity that is associated with the sending authorization policy. This identity permits Amazon Cognito to send for the email address specified in the
From
parameter.BlockEmail (dict) –
The template for the email message that your user pool sends when a detected risk event is blocked.
Subject (string) – [REQUIRED]
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
NoActionEmail (dict) –
The template for the email message that your user pool sends when no action is taken in response to a detected risk.
Subject (string) – [REQUIRED]
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
MfaEmail (dict) –
The template for the email message that your user pool sends when MFA is challenged in response to a detected risk.
Subject (string) – [REQUIRED]
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
Actions (dict) – [REQUIRED]
A list of account-takeover actions for each level of risk that Amazon Cognito might assess with threat protection.
LowAction (dict) –
The action that you assign to a low-risk assessment by threat protection.
Notify (boolean) – [REQUIRED]
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) – [REQUIRED]
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
MediumAction (dict) –
The action that you assign to a medium-risk assessment by threat protection.
Notify (boolean) – [REQUIRED]
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) – [REQUIRED]
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
HighAction (dict) –
The action that you assign to a high-risk assessment by threat protection.
Notify (boolean) – [REQUIRED]
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) – [REQUIRED]
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
RiskExceptionConfiguration (dict) –
A set of IP-address overrides to threat protection. You can set up IP-address always-block and always-allow lists.
BlockedIPRangeList (list) –
An always-block IP address list. Overrides the risk decision and always blocks authentication requests. This parameter is displayed and set in CIDR notation.
(string) –
SkippedIPRangeList (list) –
An always-allow IP address list. Risk detection isn’t performed on the IP addresses in this range list. This parameter is displayed and set in CIDR notation.
(string) –
- Return type:
dict
- Returns:
Response Syntax
{ 'RiskConfiguration': { 'UserPoolId': 'string', 'ClientId': 'string', 'CompromisedCredentialsRiskConfiguration': { 'EventFilter': [ 'SIGN_IN'|'PASSWORD_CHANGE'|'SIGN_UP', ], 'Actions': { 'EventAction': 'BLOCK'|'NO_ACTION' } }, 'AccountTakeoverRiskConfiguration': { 'NotifyConfiguration': { 'From': 'string', 'ReplyTo': 'string', 'SourceArn': 'string', 'BlockEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' }, 'NoActionEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' }, 'MfaEmail': { 'Subject': 'string', 'HtmlBody': 'string', 'TextBody': 'string' } }, 'Actions': { 'LowAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' }, 'MediumAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' }, 'HighAction': { 'Notify': True|False, 'EventAction': 'BLOCK'|'MFA_IF_CONFIGURED'|'MFA_REQUIRED'|'NO_ACTION' } } }, 'RiskExceptionConfiguration': { 'BlockedIPRangeList': [ 'string', ], 'SkippedIPRangeList': [ 'string', ] }, 'LastModifiedDate': datetime(2015, 1, 1) } }
Response Structure
(dict) –
RiskConfiguration (dict) –
The API response that contains the risk configuration that you set and the timestamp of the most recent change.
UserPoolId (string) –
The ID of the user pool that has the risk configuration applied.
ClientId (string) –
The app client where this configuration is applied. When this parameter isn’t present, the risk configuration applies to all user pool app clients that don’t have client-level settings.
CompromisedCredentialsRiskConfiguration (dict) –
Settings for compromised-credentials actions and authentication types with threat protection in full-function
ENFORCED
mode.EventFilter (list) –
Settings for the sign-in activity where you want to configure compromised-credentials actions. Defaults to all events.
(string) –
Actions (dict) –
Settings for the actions that you want your user pool to take when Amazon Cognito detects compromised credentials.
EventAction (string) –
The action that Amazon Cognito takes when it detects compromised credentials.
AccountTakeoverRiskConfiguration (dict) –
The settings for automated responses and notification templates for adaptive authentication with threat protection.
NotifyConfiguration (dict) –
The settings for composing and sending an email message when threat protection assesses a risk level with adaptive authentication. When you choose to notify users in
AccountTakeoverRiskConfiguration
, Amazon Cognito sends an email message using the method and template that you set with this data type.From (string) –
The email address that sends the email message. The address must be either individually verified with Amazon Simple Email Service, or from a domain that has been verified with Amazon SES.
ReplyTo (string) –
The reply-to email address of an email template.
SourceArn (string) –
The Amazon Resource Name (ARN) of the identity that is associated with the sending authorization policy. This identity permits Amazon Cognito to send for the email address specified in the
From
parameter.BlockEmail (dict) –
The template for the email message that your user pool sends when a detected risk event is blocked.
Subject (string) –
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
NoActionEmail (dict) –
The template for the email message that your user pool sends when no action is taken in response to a detected risk.
Subject (string) –
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
MfaEmail (dict) –
The template for the email message that your user pool sends when MFA is challenged in response to a detected risk.
Subject (string) –
The subject of the threat protection email notification.
HtmlBody (string) –
The body of an email notification formatted in HTML. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.TextBody (string) –
The body of an email notification formatted in plaintext. Choose an
HtmlBody
or aTextBody
to send an HTML-formatted or plaintext message, respectively.
Actions (dict) –
A list of account-takeover actions for each level of risk that Amazon Cognito might assess with threat protection.
LowAction (dict) –
The action that you assign to a low-risk assessment by threat protection.
Notify (boolean) –
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) –
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
MediumAction (dict) –
The action that you assign to a medium-risk assessment by threat protection.
Notify (boolean) –
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) –
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
HighAction (dict) –
The action that you assign to a high-risk assessment by threat protection.
Notify (boolean) –
Determines whether Amazon Cognito sends a user a notification message when your user pools assesses a user’s session at the associated risk level.
EventAction (string) –
The action to take for the attempted account takeover action for the associated risk level. Valid values are as follows:
BLOCK
: Block the request.MFA_IF_CONFIGURED
: Present an MFA challenge if possible. MFA is possible if the user pool has active MFA methods that the user can set up. For example, if the user pool only supports SMS message MFA but the user doesn’t have a phone number attribute, MFA setup isn’t possible. If MFA setup isn’t possible, allow the request.MFA_REQUIRED
: Present an MFA challenge if possible. Block the request if a user hasn’t set up MFA. To sign in with required MFA, users must have an email address or phone number attribute, or a registered TOTP factor.NO_ACTION
: Take no action. Permit sign-in.
RiskExceptionConfiguration (dict) –
Exceptions to the risk evaluation configuration, including always-allow and always-block IP address ranges.
BlockedIPRangeList (list) –
An always-block IP address list. Overrides the risk decision and always blocks authentication requests. This parameter is displayed and set in CIDR notation.
(string) –
SkippedIPRangeList (list) –
An always-allow IP address list. Risk detection isn’t performed on the IP addresses in this range list. This parameter is displayed and set in CIDR notation.
(string) –
LastModifiedDate (datetime) –
The date and time when the item was modified. Amazon Cognito returns this timestamp in UNIX epoch time format. Your SDK might render the output in a human-readable format like ISO 8601 or a Java
Date
object.
Exceptions
CognitoIdentityProvider.Client.exceptions.ResourceNotFoundException
CognitoIdentityProvider.Client.exceptions.InvalidParameterException
CognitoIdentityProvider.Client.exceptions.TooManyRequestsException
CognitoIdentityProvider.Client.exceptions.NotAuthorizedException
CognitoIdentityProvider.Client.exceptions.UserPoolAddOnNotEnabledException
CognitoIdentityProvider.Client.exceptions.CodeDeliveryFailureException
CognitoIdentityProvider.Client.exceptions.InvalidEmailRoleAccessPolicyException
CognitoIdentityProvider.Client.exceptions.InternalErrorException