Skip to content

Commit 5540077

Browse files
Copilotovertrue
andauthored
Add Apple Sign In (Sign in with Apple) provider (#301)
* Initial plan * Add Apple Sign In provider Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Merge 4.x into branch: add Twitter provider and resolve conflicts Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Revert unrelated changes (Twitter, FeiShu, PHPStan) - keep only Apple provider Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Verify id_token signature against Apple JWKS, validate claims, fix ES256 DER-to-P1363, validate config Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Resolve conflicts: rebase Apple changes on latest 4.x (with Twitter, FeiShu, WeWork, PHPStan updates) Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> * Fix phpcs (single_quote) and phpstan (string|false type) lint errors in Apple provider Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com> Co-authored-by: 安正超 <anzhengchao@gmail.com>
1 parent 8139328 commit 5540077

File tree

5 files changed

+721
-2
lines changed

5 files changed

+721
-2
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Socialite 是一个 [OAuth2](https://oauth.net/2/) 认证工具。 它的灵感
88

99
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)
1010

11-
该工具现已支持平台有:Facebook,Github,Google,Linkedin,Outlook,QQ,TAPD,支付宝,淘宝,百度,钉钉,微博,微信,抖音,飞书,Lark,豆瓣,企业微信,腾讯云,Line,Gitee,Coding,Twitter。
11+
该工具现已支持平台有:Apple,Facebook,Github,Google,Linkedin,Outlook,QQ,TAPD,支付宝,淘宝,百度,钉钉,微博,微信,抖音,飞书,Lark,豆瓣,企业微信,腾讯云,Line,Gitee,Coding,Twitter。
1212

1313
如果你喜欢我的项目并想支持我,[点击这里 :heart:](https://github.com/sponsors/overtrue)
1414

@@ -477,6 +477,24 @@ $config = [
477477
];
478478
```
479479

480+
### [Apple](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api)
481+
482+
通过 Apple 登录需要在 Apple Developer 后台创建 Service ID,并配置好 Return URLs。client_secret 可以直接提供,也可以通过 `team_id``key_id``private_key` 自动生成(推荐)。
483+
484+
> <https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens>
485+
486+
```php
487+
$config = [
488+
'apple' => [
489+
'client_id' => 'com.example.app', // Services ID
490+
'team_id' => 'XXXXXXXXXX', // Apple Developer Team ID
491+
'key_id' => 'XXXXXXXXXX', // Key ID from Apple Developer
492+
'private_key' => file_get_contents('/path/to/AuthKey_XXXXXXXXXX.p8'), // .p8 private key content
493+
'redirect' => 'https://example.com/auth/apple/callback',
494+
],
495+
];
496+
```
497+
480498
## 其他一些技巧
481499

482500
### Scopes
@@ -659,6 +677,7 @@ $user = $socialite->userFromToken($accessToken);
659677
- [Line - OAuth 2.0](https://developers.line.biz/en/docs/line-login/integrate-line-login/)
660678
- [Gitee - OAuth文档](https://gitee.com/api/v5/oauth_doc#/)
661679
- [PayPal - OAuth文档](https://developer.paypal.com/docs/log-in-with-paypal/)
680+
- [Apple - Sign in with Apple REST API](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api)
662681

663682
## PHP 扩展包开发
664683

README_EN.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Socialite is an [OAuth2](https://oauth.net/2/) Authentication tool. It is inspi
88

99
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue)
1010

11-
This tool now supports platforms such as Facebook, GitHub, Google, Figma, LinkedIn, Outlook, QQ, Tapd, Alipay, Taobao, Baidu, DingTalk, Weibo, WeChat, Douyin, Feishu, Lark, Douban, WeWork, Tencent Cloud, Line, Gitee, Coding and Twitter.
11+
This tool now supports platforms such as Apple, Facebook, GitHub, Google, Figma, LinkedIn, Outlook, QQ, Tapd, Alipay, Taobao, Baidu, DingTalk, Weibo, WeChat, Douyin, Feishu, Lark, Douban, WeWork, Tencent Cloud, Line, Gitee, Coding and Twitter.
1212

1313
如果你喜欢我的项目并想支持我,[点击这里 :heart:](https://github.com/sponsors/overtrue)
1414

@@ -461,6 +461,24 @@ $config = [
461461
];
462462
```
463463

464+
### [Apple](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api)
465+
466+
Sign in with Apple requires creating a Service ID in the Apple Developer portal. You can provide a `client_secret` directly or let it be generated automatically from `team_id`, `key_id`, and `private_key` (recommended).
467+
468+
> https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens
469+
470+
```php
471+
$config = [
472+
'apple' => [
473+
'client_id' => 'com.example.app', // Services ID
474+
'team_id' => 'XXXXXXXXXX', // Apple Developer Team ID
475+
'key_id' => 'XXXXXXXXXX', // Key ID from Apple Developer
476+
'private_key' => file_get_contents('/path/to/AuthKey_XXXXXXXXXX.p8'), // .p8 private key content
477+
'redirect' => 'https://example.com/auth/apple/callback',
478+
],
479+
];
480+
```
481+
464482

465483

466484
## Some Skill
@@ -648,6 +666,7 @@ $user = $socialite->userFromToken($accessToken);
648666
- [Line - OAuth 2.0](https://developers.line.biz/en/docs/line-login/integrate-line-login/)
649667
- [Gitee - OAuth文档](https://gitee.com/api/v5/oauth_doc#/)
650668
- [PayPal - OAuth文档](https://developer.paypal.com/docs/log-in-with-paypal/)
669+
- [Apple - Sign in with Apple REST API](https://developer.apple.com/documentation/sign_in_with_apple/sign_in_with_apple_rest_api)
651670

652671
[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue)
653672

0 commit comments

Comments
 (0)