hobbii / laravel-cognito-client
A Laravel wrapper for hobbii/cognito-client
Installs: 2 307
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.4|^8.0
- guzzlehttp/guzzle: ^7.0
- hobbii/cognito-client: ^1.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- fakerphp/faker: ^1.19
- orchestra/testbench: ^6.24
- phpstan/phpstan: ^1.5
- phpunit/phpunit: ^9.5
README
A public composer pacakge, adding a Cognito Client for Laravel using hobbii/cognito-client
composer require hobbii/laravel-cognito-client
Installation
Add the following environment variables:
AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION= COGNITO_APP_CLIENT_ID= COGNITO_APP_CLIENT_SECRET= COGNITO_USER_POOL_ID=
Usage
Use the hobbii
-driver with socialite:
<?php use Illuminate\Http\Request; use Hobbii\LaravelCognitoClient\Facades\Cognito; class AuthController extends Controller { public function login(Request $request) { $authSession = Cognito::authenticate($request->email, $request->password); if ($authSession->success()) { return redirect()->route('dashboard'); } return back()->withErrors([ 'email' => 'Invalid email or password!' ]); } }
Customisation
Publish the configuration file to customise settings, by running
php artisan vendor:publish --provider="Hobbii\LaravelCognitoClient\CognitoClientServiceProvider" --tag=config
Customise the configurations in config/hobbii-cognito.php
.
Testing
You can find tests in the /tests
folder, and you can run them by using ./vendor/bin/phpunit
.
Static analysis
You can run PHPStan, by executing ./vendor/bin/phpstan analyse
License
All contents of this package are licensed under the MIT license.