Giter Site home page Giter Site logo

php-apple-signin's Introduction

php-apple-signin

PHP library to manage Sign In with Apple identifier tokens, and validate them server side passed through by the iOS client.

Installation

Use composer to manage your dependencies and download php-apple-signin:

composer require griffinledingham/php-apple-signin

Example

<?php
use AppleSignIn\ASDecoder;

$clientUser = "example_client_user";
$identityToken = "example_encoded_jwt";

$appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);

/**
 * Obtain the Sign In with Apple email and user creds.
 */
$email = $appleSignInPayload->getEmail();
$user = $appleSignInPayload->getUser();

/**
 * Determine whether the client-provided user is valid.
 */
$isValid = $appleSignInPayload->verifyUser($clientUser);

?>

php-apple-signin's People

Contributors

davide555 avatar griffinledingham avatar koenpunt avatar kostanjevec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-apple-signin's Issues

[recommend] The new fork solves most of the current problems

When I encountered problems, I noticed that the manager of the project had not been maintained for a long time, resulting in many unsolved problems, and the submitted pull requests could not be processed in time. Now I have created a new fork to solve the problems I encountered and solve the problems in the current issues, including #11 #12 #20 #9 #7 , which can be replaced safely. If there are new problems, they will be corrected in time.

https://github.com/Yanlong-LI/php-apple-signin

https://packagist.org/packages/yanlongli/php-apple-signin

Apple multiple Public keys

The decoding of the JSON web token, which is created when logging in with the Apple SignIn process, sometimes fails due to a SignatureInvalidException.

I found out that Apple delivers several public keys via "https://appleid.apple.com/auth/keys". With Apple SignIn, one of these keys happens to be used for the JWT. However, the ASDecoder is fixed on a specific index of the key array.

This leads to this exception because an incorrect public key is used for decoding.

Is verification useful?

This program can verify if the identityToken is valid with clientUser.
But it didn't verify if the clientUser is from the app I wish to verify (Service ID, Team ID)
Meaning any apps can verify and return true in this program..

Undefined property: stdClass::$kid

While using the package I got an error saying "Undefined property: stdClass::$kid"

It happened in: AppleSignIn\Vendor\JWT::getPublicKeyKid at line 158.

Version: ^1.1
php version: 8.1

The code I'm using:

            $appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);

            /**
             * Obtain the Sign In with Apple email and user creds.
             */
            $email = $appleSignInPayload->getEmail();
            $userId = $appleSignInPayload->getUser();

That would be all I'm doing with the package. Should I change something? any help is worthy :)

Need to install it without composer

Hello support,
I'm using the older version of Codeigniter and it has no support for composer, can you let me know if I can install it without using the composer?
Thank you so much.

not support composer 2.0

PHP Fatal error: Uncaught Error: Class 'AppleSignIn\ASPayload' not found

Only supports composer 1.10.20

file_get_contents not working on server

I have issues with file_get_contents on my server for some yet unknown reason. I get the error below.

PHP Warning: file_get_contents(https://appleid.apple.com/auth/keys): failed to open stream: Connection refused in php shell code on line 1

It works locally and on my staging server, but not on production. It might have to do something with the server settings. It works if I replace it with CURL. Did anyone experience the same issue?

I suggest using CURL instead of file_get_contents since it's more secure in general.

Class 'ExpiredException' not found

Hello,
I have tried this plugin in my Yii2 project and unfortunately, I get the error regarding the exception.
And in my case, I get the errors with the following exceptions from vendor:

  1. SignatureInvalidException
  2. BeforeValidException
  3. ExpiredException

The JWT.php code file image reference
image

Error image reference
image

ES256 not supported

Apple uses ES256 algorithm for their keys, but the JWT.php included in this package does not support ES256.

Getting Fatal error: Uncaught Error: Class 'Firebase\JWT\ExpiredException'

hello,

downloaded this project then update composer
and add testing code on new file index.php

require_once 'Vendor/autoload.php';
use AppleSignIn\ASDecoder;

$identityToken = " <id_token>";
$appleSignInPayload = ASDecoder::getAppleSignInPayload($identityToken);
print_r($appleSignInPayload);

but i getting some fatal error -

Fatal error: Uncaught Error: Class 'Firebase\JWT\ExpiredException' not found in D:\xampp\htdocs\folder\php-apple-signin-master\Vendor\JWT.php:138 Stack trace: #0 D:\xampp\htdocs\folder\php-apple-signin-master\ASDecoder.php(46): AppleSignIn\Vendor\JWT::decode('eyJraWQiOiJlWGF...', '-----BEGIN PUBL...', Array) #1 D:\xampp\htdocs\folder\php-apple-signin-master\ASDecoder.php(28): AppleSignIn\ASDecoder::decodeIdentityToken('eyJraWQiOiJlWGF...') #2 D:\xampp\htdocs\folder\php-apple-signin-master\index.php(10): AppleSignIn\ASDecoder::getAppleSignInPayload('eyJraWQiOiJlWGF...') #3 {main} thrown in D:\xampp\htdocs\folder\php-apple-signin-master\Vendor\JWT.php on line 138

Please help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.