AWS Cognito provider for Laravel Authentication

dev-master 2020-06-10 09:07 UTC

This package is auto-updated.

Last update: 2020-07-10 09:17:45 UTC


README

Build Code Coverage Scrutinizer Code Quality

Laravel Cognito Provider 🔑

This library provides a CognitoUserProvider for Laravel.

Installation

composer require customergauge/laravel-cognito-provider

Usage

Auth configuration

In the auth.php file, add the following settings:

Default Guard

    'defaults' => [
        'guard' => 'cognito-token',
        'passwords' => 'users',
    ],

The new Guard configuration

    'guards' => [
        'cognito-token' => [
            'driver' => 'token',
            'provider' => 'cognito-provider',
            'storage_key' => 'cognito_token',
            'hash' => false,
        ],
    ],

The User Provider configuration

    'providers' => [
        'cognito-provider' => [
            'driver' => \CustomerGauge\Cognito\CognitoUserProvider::class,
        ],
    ],

Cognito Environment Variables

    /*
    |--------------------------------------------------------------------------
    | Cognito Custom Configuration
    |--------------------------------------------------------------------------
    |
    | The following configuration is not part of standard Laravel application.
    | We use it to configure the CognitoUserProvider process so that we can
    | properly validate the JWT token provided by AWS Cognito.
    |
    */

    'cognito' => [
        'pool' => env('AWS_COGNITO_USER_POOL_ID'),
        'region' => env('AWS_COGNITO_USER_POOL_REGION'),
    ],

Auth Middleware

Configure the auth middleware at App\Http\Kernel with 'auth:cognito-token'