ellaisys / aws-cognito

AWS Cognito package (with MFA Feature) using the AWS SDK for PHP/Laravel
https://ellaisys.github.io/aws-cognito/
MIT License
107 stars 42 forks source link

Breaking change implemented with JWT update #101

Open phpsa opened 1 week ago

phpsa commented 1 week ago

Describe the bug Since 1.2.5 (or 1.2.4) cannot trigger a reset request for users password,

resolve(Ellaisys\Cognito\AwsCognitoClient::class)->sendResetLink('xxxxx')

   Aws\Auth\Exception\UnresolvedAuthSchemeException  Could not resolve an authentication scheme: The service does not support `smithy.api#noAuth` authentication.

this worked on 1.2.3

config as follows:

[
    "credentials" => [
      "key" => "A...",
      "secret" => "S...",
      "token" => null,
    ],
    "app_client_id" => "6...",
    "app_client_secret" => null,
    "user_pool_id" => "ap-southeast-2_???",
    "region" => "ap-southeast-2",
    "version" => "latest",
    "app_client_secret_allow" => false,
    "cognito_user_fields" => [
      "name" => "name",
      "given_name" => null,
      "middle_name" => null,
      "family_name" => null,
      "nickname" => null,
      "preferred_username" => null,
      "email" => "email",
      "phone_number" => "phone",
      "gender" => null,
      "birthdate" => null,
      "locale" => null,
    ],
    "add_user_delivery_mediums" => "EMAIL",
    "default_user_group" => null,
    "mfa_setup" => "MFA_NONE",
    "force_mfa_code_route_name" => "cognito.form.mfa.code",
    "mfa_type" => "SOFTWARE_TOKEN_MFA",
    "add_missing_local_user" => false,
    "delete_user" => true,
    "sso_user_model" => "App\User",
    "storage_provider" => "redis",
    "forced_challenge_names" => [
      "NEW_PASSWORD_REQUIRED",
      "RESET_REQUIRED",
    ],
    "force_password_change_web" => false,
    "force_redirect_route_name" => "cognito.form.change.password",
    "force_password_change_api" => false,
    "force_password_auto_update_api" => true,
    "allow_forgot_password_resend" => true,
    "force_new_user_email_verified" => true,
    "new_user_message_action" => "SUPPRESS",
    "force_new_user_password" => true,
    "mfa_qr_library" => "https://quickchart.io/qr?size=200&text=",
    "add_missing_local_user_sso" => false,
  ]

Producttion Code:

<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Password;
use Illuminate\Validation\ValidationException;
use Ellaisys\Cognito\Auth\SendsPasswordResetEmails;
use Ellaisys\Cognito\AwsCognitoClient;

//Added for AWS Cognito

class PasswordResetLinkController extends Controller
{
    use SendsPasswordResetEmails;

    public function __construct()
    {
        $this->middleware('aws-cognito');
    }

    /**
     * Handle an incoming password reset link request.
     *
     * @throws \Illuminate\Validation\ValidationException
     */
    public function store(Request $request): JsonResponse
    {
        $request->validate([
            'email' => ['required', 'email'],
        ]);

        /** @var array */
        $response = $this->sendResetLinkEmail($request, 'email', resetTypeCode: true, isJsonResponse: true);

        return response()->json($response['response']);
    }
}

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

amitdhongde commented 4 days ago

@phpsa Thank you for sharing the issue. We will review it on priority and have that fixed asap.

amitdhongde commented 3 days ago

@phpsa We were not able to replicate the issue. We used the same code shared above, and that works fine. We tested it with the latest released version v1.2.5 and updated packages.

image image

Can you please recheck and confirm?