Simple laravel package to work with aws-php-sdk and amazon cognito. Once installed it can generate api routes to work with cognito apis and generate and validate jwt tokens
You can install the package via composer:
composer require iwouldrathercode/cognito
Run the setup command to install dependencies and link the storage folder to public folder
php artisan cognito:setup
Run the install command to publish the config files and migrations
php artisan cognito:install
Execute the migrations. This will update the users table and since passwords are no longer managed by laravel, this will also delete the password_resets table
php artisan migrate
Update the config/auth.php with default guard as api
..
..
'defaults' => [
'guard' => 'api',
'passwords' => 'users',
],
..
..
Update the config/auth.php, guards array with config of api
using 'cognito' as driver
..
..
'guards' => [
..
..
'api' => [
'driver' => 'cognito',
'provider' => 'users'
]
],
..
..
Ensure the env variables of the cognito UserPool and ClientID are at .env this will affect congig/cognito.php
config file
AWS_COGNITO_USER_POOL_ID=
AWS_COGNITO_CLIENT_ID=
AWS_DEFAULT_REGION=
This package will create /api routes to manage authentication
POST -> api/confirm-forgot-password -> confirm-forgot-password ›
Iwouldrathercode\Cognito\Http\Controllers\SelfServiceController@confirmForgotPassword
POST -> api/forgot-password -> forgot-password › Iwouldrathercode\Cognito\Http\Controllers\SelfServiceController@forgotPassword
POST -> api/login -> signin ›
Iwouldrathercode\Cognito\Http\Controllers\LoginController@login
POST -> api/register -> signup ›
Iwouldrathercode\Cognito\Http\Controllers\RegisterController@register
POST -> api/verify -> verify ›
Iwouldrathercode\Cognito\Http\Controllers\EmailVerificationController@verify
POST -> api/logout -> signout ›
Iwouldrathercode\Cognito\Http\Controllers\LoginController@logout
- Create valid Unit Test cases
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.