1
JulAWS Cognito package provides a simple way to use AWS Cognito authentication in Laravel 7.x for Web and API Auth Drivers.
You can install the package via composer.
composer require ellaisys/aws-cognito
In order to use AWS Cognito as an authentication provider, you require a Cognito User Pool.
If you haven't created one, go to your Amazon management console and create a new user pool.
Next, generate an App Client. This will give you the App client id and the App client secret you need for your .env file.
IMPORTANT: Don't forget to activate the checkbox to Enable sign-in API for server-based Authentication. The Auth Flow is called: ADMIN_USER_PASSWORD_AUTH (formerly ADMIN_NO_SRP_AUTH)
AWS IAM configuration You also need a new IAM Role with the following Access Rights:
Add the following fields to your .env file and set the values according to your AWS settings:
# AWS configurations for cloud storage
AWS_ACCESS_KEY_ID="Axxxxxxxxxxxxxxxxxxxxxxxx6"
AWS_SECRET_ACCESS_KEY="mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+"
# AWS Cognito configurations
AWS_COGNITO_CLIENT_ID="6xxxxxxxxxxxxxxxxxxxxxxxxr"
AWS_COGNITO_CLIENT_SECRET="1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1"
AWS_COGNITO_USER_POOL_ID="xxxxxxxxxxxxxxxxx"
AWS_COGNITO_REGION="xxxxxxxxxxx" //optional - default value is 'us-east-1'
AWS_COGNITO_VERSION="latest" //optional - default value is 'latest'
Our package is providing you 6 traits you can just add to your Auth Controllers to get our package running.
Ellaisys\Cognito\Auth\AuthenticatesUsers Ellaisys\Cognito\Auth\RegistersUsers Ellaisys\Cognito\Auth\ResetsPasswords Ellaisys\Cognito\Auth\RespondsMFAChallenge Ellaisys\Cognito\Auth\SendsPasswordResetEmails Ellaisys\Cognito\Auth\VerifiesEmails ```
In the simplest way you just go through your Auth Controllers and change namespaces from the traits which are currently implemented from Laravel.
You can change the structure to suit your needs. Please be aware of the @extend statement in the blade file to fit into your project structure. At the current state, you need to have those 4 form fields defined here. Those are token, email, password, and password_confirmation.
Here's the basic introduction, For more details, you can visit Github
Published at : 01-07-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project