Skip to content

Helper written by PHP to get through SRP authentication for Amazon Cognito.

License

Notifications You must be signed in to change notification settings

yasuaki640/cognito-srp-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cognito-srp-php

Helper written by PHP to get through SRP authentication for Amazon Cognito.

This was written in reference to the jenky/AwsCognitoIdentitySRP.php.

Install

composer require yasuaki640/cognito-srp-php

Usage

    // instantiate aws client
    $client = new CognitoIdentityProviderClient([
        ...
    ]);

    // instantiate helper
    $srpHelper = new CognitoSrp(
        'your client id',
        'your pool id',
        'your client secret (if set)',
    );
    
    $result = $client->adminInitiateAuth([
        'AuthFlow' => 'USER_SRP_AUTH',
        'ClientId' => 'your client id',
        'UserPoolId' => 'your pool id',
        'AuthParameters' => [
            'USERNAME' => $username,
             // calculate A
            'SRP_A' => $srpHelper->SRP_A(),
             // calculate secret Hash
            'SECRET_HASH' => $srpHelper->SECRET_HASH($username),
        ],
    ]);

    $authRes = $client->adminRespondToAuthChallenge([
        'ChallengeName' => 'PASSWORD_VERIFIER',
        'UserPoolId' => 'your pool id',
        'ClientId' => 'your client id',
        // generate authentication challenge response params
        'ChallengeResponses' => $srpHelper->ChallengeResponses($result, $username, $password), 
    ]);

About

Helper written by PHP to get through SRP authentication for Amazon Cognito.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages