aws_sdk_cognitoidentityprovider/client/initiate_auth.rs
1// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
2impl super::Client {
3 /// Constructs a fluent builder for the [`InitiateAuth`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder) operation.
4 ///
5 /// - The fluent builder is configurable:
6 /// - [`auth_flow(AuthFlowType)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::auth_flow) / [`set_auth_flow(Option<AuthFlowType>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_auth_flow):<br>required: **true**<br><p>The authentication flow that you want to initiate. Each <code>AuthFlow</code> has linked <code>AuthParameters</code> that you must submit. The following are some example flows.</p> <dl> <dt> USER_AUTH </dt> <dd> <p>The entry point for <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flows-selection-sdk.html#authentication-flows-selection-choice">choice-based authentication</a> with passwords, one-time passwords, and WebAuthn authenticators. Request a preferred authentication type or review available authentication types. From the offered authentication types, select one in a challenge response and then authenticate with that method in an additional challenge response. To activate this setting, your user pool must be in the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/feature-plans-features-essentials.html"> Essentials tier</a> or higher.</p> </dd> <dt> USER_SRP_AUTH </dt> <dd> <p>Username-password authentication with the Secure Remote Password (SRP) protocol. For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-authentication-flow.html#Using-SRP-password-verification-in-custom-authentication-flow">Use SRP password verification in custom authentication flow</a>.</p> </dd> <dt> REFRESH_TOKEN_AUTH and REFRESH_TOKEN </dt> <dd> <p>Receive new ID and access tokens when you pass a <code>REFRESH_TOKEN</code> parameter with a valid refresh token as the value. For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-the-refresh-token.html">Using the refresh token</a>.</p> </dd> <dt> CUSTOM_AUTH </dt> <dd> <p>Custom authentication with Lambda triggers. For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-challenge.html">Custom authentication challenge Lambda triggers</a>.</p> </dd> <dt> USER_PASSWORD_AUTH </dt> <dd> <p>Client-side username-password authentication with the password sent directly in the request. For more information about client-side and server-side authentication, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flows-public-server-side.html">SDK authorization models</a>.</p> </dd> </dl> <p><code>ADMIN_USER_PASSWORD_AUTH</code> is a flow type of <code>AdminInitiateAuth</code> and isn't valid for InitiateAuth. <code>ADMIN_NO_SRP_AUTH</code> is a legacy server-side username-password flow and isn't valid for InitiateAuth.</p><br>
7 /// - [`auth_parameters(impl Into<String>, impl Into<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::auth_parameters) / [`set_auth_parameters(Option<HashMap::<String, String>>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_auth_parameters):<br>required: **false**<br><p>The authentication parameters. These are inputs corresponding to the <code>AuthFlow</code> that you're invoking.</p> <p>The following are some authentication flows and their parameters. Add a <code>SECRET_HASH</code> parameter if your app client has a client secret. Add <code>DEVICE_KEY</code> if you want to bypass multi-factor authentication with a remembered device.</p> <dl> <dt> USER_AUTH </dt> <dd> <ul> <li> <p><code>USERNAME</code> (required)</p></li> <li> <p><code>PREFERRED_CHALLENGE</code>. If you don't provide a value for <code>PREFERRED_CHALLENGE</code>, Amazon Cognito responds with the <code>AvailableChallenges</code> parameter that specifies the available sign-in methods.</p></li> </ul> </dd> <dt> USER_SRP_AUTH </dt> <dd> <ul> <li> <p><code>USERNAME</code> (required)</p></li> <li> <p><code>SRP_A</code> (required)</p></li> </ul> </dd> <dt> USER_PASSWORD_AUTH </dt> <dd> <ul> <li> <p><code>USERNAME</code> (required)</p></li> <li> <p><code>PASSWORD</code> (required)</p></li> </ul> </dd> <dt> REFRESH_TOKEN_AUTH/REFRESH_TOKEN </dt> <dd> <ul> <li> <p><code>REFRESH_TOKEN</code>(required)</p></li> </ul> </dd> <dt> CUSTOM_AUTH </dt> <dd> <ul> <li> <p><code>USERNAME</code> (required)</p></li> <li> <p><code>ChallengeName: SRP_A</code> (when doing SRP authentication before custom challenges)</p></li> <li> <p><code>SRP_A: (An SRP_A value)</code> (when doing SRP authentication before custom challenges)</p></li> </ul> </dd> </dl> <p>For more information about <code>SECRET_HASH</code>, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/signing-up-users-in-your-app.html#cognito-user-pools-computing-secret-hash">Computing secret hash values</a>. For information about <code>DEVICE_KEY</code>, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-device-tracking.html">Working with user devices in your user pool</a>.</p><br>
8 /// - [`client_metadata(impl Into<String>, impl Into<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::client_metadata) / [`set_client_metadata(Option<HashMap::<String, String>>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_client_metadata):<br>required: **false**<br><p>A map of custom key-value pairs that you can provide as input for certain custom workflows that this action triggers.</p> <p>You create custom workflows by assigning Lambda functions to user pool triggers. When you send an <code>InitiateAuth</code> request, Amazon Cognito invokes the Lambda functions that are specified for various triggers. The <code>ClientMetadata</code> value is passed as input to the functions for only the following triggers.</p> <ul> <li> <p>Pre sign-up</p></li> <li> <p>Pre authentication</p></li> <li> <p>User migration</p></li> </ul> <p>When Amazon Cognito invokes the functions for these triggers, it passes a JSON payload as input to the function. This payload contains a <code>validationData</code> attribute with the data that you assigned to the <code>ClientMetadata</code> parameter in your <code>InitiateAuth</code> request. In your function, <code>validationData</code> can contribute to operations that require data that isn't in the default payload.</p> <p><code>InitiateAuth</code> requests invokes the following triggers without <code>ClientMetadata</code> as input.</p> <ul> <li> <p>Post authentication</p></li> <li> <p>Custom message</p></li> <li> <p>Pre token generation</p></li> <li> <p>Create auth challenge</p></li> <li> <p>Define auth challenge</p></li> <li> <p>Custom email sender</p></li> <li> <p>Custom SMS sender</p></li> </ul> <p>For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html"> Using Lambda triggers</a> in the <i>Amazon Cognito Developer Guide</i>.</p><note> <p>When you use the <code>ClientMetadata</code> parameter, note that Amazon Cognito won't do the following:</p> <ul> <li> <p>Store the <code>ClientMetadata</code> value. This data is available only to Lambda triggers that are assigned to a user pool to support custom workflows. If your user pool configuration doesn't include triggers, the <code>ClientMetadata</code> parameter serves no purpose.</p></li> <li> <p>Validate the <code>ClientMetadata</code> value.</p></li> <li> <p>Encrypt the <code>ClientMetadata</code> value. Don't send sensitive information in this parameter.</p></li> </ul> </note><br>
9 /// - [`client_id(impl Into<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::client_id) / [`set_client_id(Option<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_client_id):<br>required: **true**<br><p>The ID of the app client that your user wants to sign in to.</p><br>
10 /// - [`analytics_metadata(AnalyticsMetadataType)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::analytics_metadata) / [`set_analytics_metadata(Option<AnalyticsMetadataType>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_analytics_metadata):<br>required: **false**<br><p>Information that supports analytics outcomes with Amazon Pinpoint, including the user's endpoint ID. The endpoint ID is a destination for Amazon Pinpoint push notifications, for example a device identifier, email address, or phone number.</p><br>
11 /// - [`user_context_data(UserContextDataType)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::user_context_data) / [`set_user_context_data(Option<UserContextDataType>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_user_context_data):<br>required: **false**<br><p>Contextual data about your user session like the device fingerprint, IP address, or location. Amazon Cognito threat protection evaluates the risk of an authentication event based on the context that your app generates and passes to Amazon Cognito when it makes API requests.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-viewing-threat-protection-app.html">Collecting data for threat protection in applications</a>.</p><br>
12 /// - [`session(impl Into<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::session) / [`set_session(Option<String>)`](crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::set_session):<br>required: **false**<br><p>The optional session ID from a <code>ConfirmSignUp</code> API request. You can sign in a user directly from the sign-up process with the <code>USER_AUTH</code> authentication flow. When you pass the session ID to <code>InitiateAuth</code>, Amazon Cognito assumes the SMS or email message one-time verification password from <code>ConfirmSignUp</code> as the primary authentication factor. You're not required to submit this code a second time. This option is only valid for users who have confirmed their sign-up and are signing in for the first time within the authentication flow session duration of the session ID.</p><br>
13 /// - On success, responds with [`InitiateAuthOutput`](crate::operation::initiate_auth::InitiateAuthOutput) with field(s):
14 /// - [`challenge_name(Option<ChallengeNameType>)`](crate::operation::initiate_auth::InitiateAuthOutput::challenge_name): <p>The name of an additional authentication challenge that you must respond to.</p> <p>Possible challenges include the following:</p><note> <p>All of the following challenges require <code>USERNAME</code> and, when the app client has a client secret, <code>SECRET_HASH</code> in the parameters. Include a <code>DEVICE_KEY</code> for device authentication.</p> </note> <ul> <li> <p><code>WEB_AUTHN</code>: Respond to the challenge with the results of a successful authentication with a WebAuthn authenticator, or passkey, as <code>CREDENTIAL</code>. Examples of WebAuthn authenticators include biometric devices and security keys.</p></li> <li> <p><code>PASSWORD</code>: Respond with the user's password as <code>PASSWORD</code>.</p></li> <li> <p><code>PASSWORD_SRP</code>: Respond with the initial SRP secret as <code>SRP_A</code>.</p></li> <li> <p><code>SELECT_CHALLENGE</code>: Respond with a challenge selection as <code>ANSWER</code>. It must be one of the challenge types in the <code>AvailableChallenges</code> response parameter. Add the parameters of the selected challenge, for example <code>USERNAME</code> and <code>SMS_OTP</code>.</p></li> <li> <p><code>SMS_MFA</code>: Respond with the code that your user pool delivered in an SMS message, as <code>SMS_MFA_CODE</code></p></li> <li> <p><code>EMAIL_MFA</code>: Respond with the code that your user pool delivered in an email message, as <code>EMAIL_MFA_CODE</code></p></li> <li> <p><code>EMAIL_OTP</code>: Respond with the code that your user pool delivered in an email message, as <code>EMAIL_OTP_CODE</code> .</p></li> <li> <p><code>SMS_OTP</code>: Respond with the code that your user pool delivered in an SMS message, as <code>SMS_OTP_CODE</code>.</p></li> <li> <p><code>PASSWORD_VERIFIER</code>: Respond with the second stage of SRP secrets as <code>PASSWORD_CLAIM_SIGNATURE</code>, <code>PASSWORD_CLAIM_SECRET_BLOCK</code>, and <code>TIMESTAMP</code>.</p></li> <li> <p><code>CUSTOM_CHALLENGE</code>: This is returned if your custom authentication flow determines that the user should pass another challenge before tokens are issued. The parameters of the challenge are determined by your Lambda function and issued in the <code>ChallengeParameters</code> of a challenge response.</p></li> <li> <p><code>DEVICE_SRP_AUTH</code>: Respond with the initial parameters of device SRP authentication. For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-device-tracking.html#user-pools-remembered-devices-signing-in-with-a-device">Signing in with a device</a>.</p></li> <li> <p><code>DEVICE_PASSWORD_VERIFIER</code>: Respond with <code>PASSWORD_CLAIM_SIGNATURE</code>, <code>PASSWORD_CLAIM_SECRET_BLOCK</code>, and <code>TIMESTAMP</code> after client-side SRP calculations. For more information, see <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-device-tracking.html#user-pools-remembered-devices-signing-in-with-a-device">Signing in with a device</a>.</p></li> <li> <p><code>NEW_PASSWORD_REQUIRED</code>: For users who are required to change their passwords after successful first login. Respond to this challenge with <code>NEW_PASSWORD</code> and any required attributes that Amazon Cognito returned in the <code>requiredAttributes</code> parameter. You can also set values for attributes that aren't required by your user pool and that your app client can write.</p> <p>Amazon Cognito only returns this challenge for users who have temporary passwords. When you create passwordless users, you must provide values for all required attributes.</p><note> <p>In a <code>NEW_PASSWORD_REQUIRED</code> challenge response, you can't modify a required attribute that already has a value. In <code>AdminRespondToAuthChallenge</code> or <code>RespondToAuthChallenge</code>, set a value for any keys that Amazon Cognito returned in the <code>requiredAttributes</code> parameter, then use the <code>AdminUpdateUserAttributes</code> or <code>UpdateUserAttributes</code> API operation to modify the value of any additional attributes.</p> </note></li> <li> <p><code>MFA_SETUP</code>: For users who are required to setup an MFA factor before they can sign in. The MFA types activated for the user pool will be listed in the challenge parameters <code>MFAS_CAN_SETUP</code> value.</p> <p>To set up time-based one-time password (TOTP) MFA, use the session returned in this challenge from <code>InitiateAuth</code> or <code>AdminInitiateAuth</code> as an input to <code>AssociateSoftwareToken</code>. Then, use the session returned by <code>VerifySoftwareToken</code> as an input to <code>RespondToAuthChallenge</code> or <code>AdminRespondToAuthChallenge</code> with challenge name <code>MFA_SETUP</code> to complete sign-in.</p> <p>To set up SMS or email MFA, collect a <code>phone_number</code> or <code>email</code> attribute for the user. Then restart the authentication flow with an <code>InitiateAuth</code> or <code>AdminInitiateAuth</code> request.</p></li> </ul>
15 /// - [`session(Option<String>)`](crate::operation::initiate_auth::InitiateAuthOutput::session): <p>The session identifier that links a challenge response to the initial authentication request. If the user must pass another challenge, Amazon Cognito returns a session ID and challenge parameters.</p>
16 /// - [`challenge_parameters(Option<HashMap::<String, String>>)`](crate::operation::initiate_auth::InitiateAuthOutput::challenge_parameters): <p>The required parameters of the <code>ChallengeName</code> challenge.</p> <p>All challenges require <code>USERNAME</code>. They also require <code>SECRET_HASH</code> if your app client has a client secret.</p>
17 /// - [`authentication_result(Option<AuthenticationResultType>)`](crate::operation::initiate_auth::InitiateAuthOutput::authentication_result): <p>The result of a successful and complete authentication request. This result is only returned if the user doesn't need to pass another challenge. If they must pass another challenge before they get tokens, Amazon Cognito returns a challenge in <code>ChallengeName</code>, <code>ChallengeParameters</code>, and <code>Session</code> response parameters.</p>
18 /// - [`available_challenges(Option<Vec::<ChallengeNameType>>)`](crate::operation::initiate_auth::InitiateAuthOutput::available_challenges): <p>This response parameter lists the available authentication challenges that users can select from in <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/authentication-flows-selection-sdk.html#authentication-flows-selection-choice">choice-based authentication</a>. For example, they might be able to choose between passkey authentication, a one-time password from an SMS message, and a traditional password.</p>
19 /// - On failure, responds with [`SdkError<InitiateAuthError>`](crate::operation::initiate_auth::InitiateAuthError)
20 pub fn initiate_auth(&self) -> crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder {
21 crate::operation::initiate_auth::builders::InitiateAuthFluentBuilder::new(self.handle.clone())
22 }
23}