All Projects → AzimoLabs → apple-sign-in-php-sdk

AzimoLabs / apple-sign-in-php-sdk

Licence: MIT license
PHP library to verify and validate Apple IdentityToken and authenticate a user with Apple ID.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to apple-sign-in-php-sdk

rhonabwy
Javascript Object Signing and Encryption (JOSE) library - JWK, JWKS, JWS, JWE and JWT
Stars: ✭ 33 (-58.23%)
Mutual labels:  jwk
jwx
JSON/JWK/JWS/JWT/Base64 library in SPARK
Stars: ✭ 15 (-81.01%)
Mutual labels:  jwk
node-jose-tools
Command line tools for node-jose's features
Stars: ✭ 29 (-63.29%)
Mutual labels:  jwk
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+3512.66%)
Mutual labels:  jwk
jwt-signature
[READ ONLY] Signature component of the JWT Framework
Stars: ✭ 32 (-59.49%)
Mutual labels:  jwk
lokey
A tool that makes it easy to work with and convert between cryptographic key formats
Stars: ✭ 87 (+10.13%)
Mutual labels:  jwk
lexik-jose-bridge
An Encoder for the LexikJWTAuthenticationBundle that uses web-token/jwt-framework
Stars: ✭ 27 (-65.82%)
Mutual labels:  jwk
jwtauthroles
Made to use JWTs from an external identity provider in Laravel. Tested with Fusionauth, but should be quite general purpose.
Stars: ✭ 14 (-82.28%)
Mutual labels:  jwk
js-keygen
ssh-keygen in the browser
Stars: ✭ 85 (+7.59%)
Mutual labels:  jwk
jwt-core
[READ-ONLY] Core component of the JWT Framework
Stars: ✭ 46 (-41.77%)
Mutual labels:  jwk
huawei-account-demo
Sample code for quickly integrate Huawei ID. HUAWEI Account Kit provides developers with simple, secure, and quick sign-in and authorization functions.
Stars: ✭ 39 (-50.63%)
Mutual labels:  sign-in
react-native-apple-authentication
React Native apple sign in
Stars: ✭ 44 (-44.3%)
Mutual labels:  apple-sign-in
titanium-apple-sign-in
Use the iOS 13+ Apple Sign In API with Titanium
Stars: ✭ 29 (-63.29%)
Mutual labels:  apple-sign-in
godot-apple-signin
Module for sign in with Apple in Godot
Stars: ✭ 27 (-65.82%)
Mutual labels:  apple-sign-in
sign-in-with-apple
An example for sign-in-with-apple, golang-version.
Stars: ✭ 22 (-72.15%)
Mutual labels:  sign-in-with-apple
sign-in-with-apple
A WordPress plugin for Sign In with Apple
Stars: ✭ 47 (-40.51%)
Mutual labels:  sign-in-with-apple
nativescript-apple-sign-in
Sign In With Apple, as seen on WWDC 2019, available with iOS 13
Stars: ✭ 37 (-53.16%)
Mutual labels:  sign-in-with-apple

Sign-in with Apple SDK

Build Status

Installation

Recommended and easiest way to installing library is through Composer.

composer require azimolabs/apple-sign-in-php-sdk

Requirements

  • PHP 7.1+
  • OpenSSL Extension

PHP support

PHP version Library version
5.x NOT SUPPORTED
> 7.0 <= 7.3 1.4.x
>= 7.4 < 8.0 1.5.x
>= 8.0 & ^7.4 2.0.x

Versioning follows semver standard.

How it works

This description assumes that you already have generated identityToken . Remember that token is valid ONLY for 10 minutes.

The first step to verify the identity token is to generate a public key. To generate public key exponent and modulus values are required. Both information are exposed in Apple API endpoint. Those values differ depending on the algorithm.

The second step is verification if provided identityToken is valid against generated public key. If so we are sure that identityToken wasn't malformed.

The third step is validation if token is not expired. Additionally it is worth to check issuer and audience, examples are shown below.

Basic usage

Once you have cloned repository, make sure that composer dependencies are installed running composer install -o.

$appleJwtFetchingService = new Auth\Service\AppleJwtFetchingService(
            new Auth\Jwt\JwtParser(new \Lcobucci\JWT\Token\Parser(new \Lcobucci\JWT\Encoding\JoseEncoder())),
            new Auth\Jwt\JwtVerifier(
                new Api\AppleApiClient(
                    new GuzzleHttp\Client(
                        [
                            'base_uri'        => 'https://appleid.apple.com',
                            'timeout'         => 5,
                            'connect_timeout' => 5,
                        ]
                    ),
                    new Api\Factory\ResponseFactory()
                ),
                new \Lcobucci\JWT\Validation\Validator(),
                new \Lcobucci\JWT\Signer\Rsa\Sha256()
            ),
            new Auth\Jwt\JwtValidator(
                new \Lcobucci\JWT\Validation\Validator(),
                [
                    new \Lcobucci\JWT\Validation\Constraint\IssuedBy('https://appleid.apple.com'),
                    new \Lcobucci\JWT\Validation\Constraint\PermittedFor('com.c.azimo.stage'),
                ]
            ),
            new Auth\Factory\AppleJwtStructFactory()
        );

$appleJwtFetchingService->getJwtPayload('your.identity.token');

If you don't want to copy-paste above code you can paste freshly generated identityToken in tests/E2e/Auth/AppleJwtFetchingServiceTest.php:53 and run tests with simple command php vendor/bin/phpunit tests/E2e.

$ php vendor/bin/phpunit tests/E2e
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.

Random seed:   1594414420

.                                                                   1 / 1 (100%)

Time: 00:00.962, Memory: 8.00 MB

OK (1 test, 1 assertion)

Todo

It is welcome to open a pull request with a fix of any issue:

Miscellaneous

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].