aws_sdk_cognitoidentityprovider/client/admin_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 [`AdminInitiateAuth`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder) operation.
4 ///
5 /// - The fluent builder is configurable:
6 /// - [`user_pool_id(impl Into<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::user_pool_id) / [`set_user_pool_id(Option<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::set_user_pool_id):<br>required: **true**<br><p>The ID of the user pool where the user wants to sign in.</p><br>
7 /// - [`client_id(impl Into<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::client_id) / [`set_client_id(Option<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::set_client_id):<br>required: **true**<br><p>The ID of the app client where the user wants to sign in.</p><br>
8 /// - [`auth_flow(AuthFlowType)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::auth_flow) / [`set_auth_flow(Option<AuthFlowType>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::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> ADMIN_USER_PASSWORD_AUTH </dt> <dd> <p>Server-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><br>
9 /// - [`auth_parameters(impl Into<String>, impl Into<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::auth_parameters) / [`set_auth_parameters(Option<HashMap::<String, String>>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::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> ADMIN_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 preceding custom authentication with SRP authentication)</p></li> <li> <p><code>SRP_A: (An SRP_A value)</code> (when preceding custom authentication with SRP authentication)</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>
10 /// - [`client_metadata(impl Into<String>, impl Into<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::client_metadata) / [`set_client_metadata(Option<HashMap::<String, String>>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::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 use the AdminInitiateAuth API action, Amazon Cognito invokes the Lambda functions that are specified for various triggers. The ClientMetadata value is passed as input to the functions for only the following triggers:</p> <ul> <li> <p>Pre signup</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, which the function receives as input. This payload contains a <code>validationData</code> attribute, which provides the data that you assigned to the ClientMetadata parameter in your AdminInitiateAuth request. In your function code in Lambda, you can process the <code>validationData</code> value to enhance your workflow for your specific needs.</p> <p>When you use the AdminInitiateAuth API action, Amazon Cognito also invokes the functions for the following triggers, but it doesn't provide the ClientMetadata value 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>
11 /// - [`analytics_metadata(AnalyticsMetadataType)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::analytics_metadata) / [`set_analytics_metadata(Option<AnalyticsMetadataType>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::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>
12 /// - [`context_data(ContextDataType)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::context_data) / [`set_context_data(Option<ContextDataType>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::set_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>
13 /// - [`session(impl Into<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::session) / [`set_session(Option<String>)`](crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::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 an <code>AuthFlow</code> of <code>USER_AUTH</code> and <code>AuthParameters</code> of <code>EMAIL_OTP</code> or <code>SMS_OTP</code>, depending on how your user pool sent the confirmation-code message.</p><br>
14 /// - On success, responds with [`AdminInitiateAuthOutput`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput) with field(s):
15 /// - [`challenge_name(Option<ChallengeNameType>)`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput::challenge_name): <p>The name of the challenge that you're responding to with this call. This is returned in the <code>AdminInitiateAuth</code> response if you must pass another challenge.</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>
16 /// - [`session(Option<String>)`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput::session): <p>The session that must be passed to challenge-response requests. If an <code>AdminInitiateAuth</code> or <code>AdminRespondToAuthChallenge</code> API request results in another authentication challenge, Amazon Cognito returns a session ID and the parameters of the next challenge. Pass this session ID in the <code>Session</code> parameter of <code>AdminRespondToAuthChallenge</code>.</p>
17 /// - [`challenge_parameters(Option<HashMap::<String, String>>)`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput::challenge_parameters): <p>The parameters of an authentication challenge. Amazon Cognito returns challenge parameters as a guide to the responses your user or application must provide for the returned <code>ChallengeName</code>. Calculate responses to the challenge parameters and pass them in the <code>ChallengeParameters</code> of <code>AdminRespondToAuthChallenge</code>.</p> <p>All challenges require <code>USERNAME</code> and, when the app client has a client secret, <code>SECRET_HASH</code>.</p> <p>In SRP challenges, Amazon Cognito returns the <code>username</code> attribute in <code>USER_ID_FOR_SRP</code> instead of any email address, preferred username, or phone number alias that you might have specified in your <code>AdminInitiateAuth</code> request. You must use the username and not an alias in the <code>ChallengeResponses</code> of your challenge response.</p>
18 /// - [`authentication_result(Option<AuthenticationResultType>)`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput::authentication_result): <p>The outcome of successful authentication. This is only returned if the user pool has no additional challenges to return. If Amazon Cognito returns another challenge, the response includes <code>ChallengeName</code>, <code>ChallengeParameters</code>, and <code>Session</code> so that your user can answer the challenge.</p>
19 /// - [`available_challenges(Option<Vec::<ChallengeNameType>>)`](crate::operation::admin_initiate_auth::AdminInitiateAuthOutput::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>
20 /// - On failure, responds with [`SdkError<AdminInitiateAuthError>`](crate::operation::admin_initiate_auth::AdminInitiateAuthError)
21 pub fn admin_initiate_auth(&self) -> crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder {
22 crate::operation::admin_initiate_auth::builders::AdminInitiateAuthFluentBuilder::new(self.handle.clone())
23 }
24}