CognitoIdentityProvider / Client / set_risk_configuration

set_risk_configuration#

CognitoIdentityProvider.Client.set_risk_configuration(**kwargs)#

Configures actions on detected risks. To delete the risk configuration for UserPoolId or ClientId, pass null values for all four configuration types.

To activate Amazon Cognito advanced security features, update the user pool to include the UserPoolAddOns key AdvancedSecurityMode.

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 user pool ID.

  • ClientId (string) –

    The app client ID. If ClientId is null, then the risk configuration is mapped to userPoolId. When the client ID is null, the same risk configuration is applied to all the clients in the userPool.

    Otherwise, ClientId is mapped to the client. When the client ID isn’t null, the user pool configuration is overridden and the risk configuration for the client is used instead.

  • CompromisedCredentialsRiskConfiguration (dict) –

    The compromised credentials risk configuration.

    • 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 account takeover risk configuration.

    • NotifyConfiguration (dict) –

      The settings for composing and sending an email message when advanced security features 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

        • TextBody (string) –

          The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

        • TextBody (string) –

          The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

        • TextBody (string) –

          The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 advanced security features.

      • LowAction (dict) –

        The action that you assign to a low-risk assessment by advanced security features.

        • 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 advanced security features.

        • 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 advanced security features.

        • 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) –

    The configuration to override the risk decision.

    • 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 risk configuration.

      • 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 advanced security features 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 advanced security features.

        • NotifyConfiguration (dict) –

          The settings for composing and sending an email message when advanced security features 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

            • TextBody (string) –

              The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

            • TextBody (string) –

              The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 a TextBody to send an HTML-formatted or plaintext message, respectively.

            • TextBody (string) –

              The body of an email notification formatted in plaintext. Choose an HtmlBody or a TextBody 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 advanced security features.

          • LowAction (dict) –

            The action that you assign to a low-risk assessment by advanced security features.

            • 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 advanced security features.

            • 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 advanced security features.

            • 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