mirror of
https://github.com/ambieco/laravel-sign-in-with-apple.git
synced 2026-01-12 22:43:49 +08:00
Add documentation.
This commit is contained in:
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# Changelog
|
||||||
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.1.0] - 2019-10-12
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- initial functionality.
|
||||||
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hello@genealabs.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
||||||
35
CONTRIBUTING.md
Normal file
35
CONTRIBUTING.md
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
# How to contribute
|
||||||
|
We welcome everyone to submit pull requests with:
|
||||||
|
- issue fixes
|
||||||
|
- change suggestions
|
||||||
|
- documentation updates
|
||||||
|
|
||||||
|
However, not every pull request will automatically be accepted. I will review each carefully to make sure it is in line with
|
||||||
|
the direction I want the package to continue in. This might mean that some pull requests are not accepted, or might stay
|
||||||
|
unmerged until a place for them can be determined.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
- [ ] After making your changes, make sure the tests still pass.
|
||||||
|
- [ ] When adding new functionality, also add new tests.
|
||||||
|
- [ ] When fixing errors write and satisfy new unit tests that replicate the issue.
|
||||||
|
- [ ] Make sure there are no build errors.
|
||||||
|
- [ ] All code must past PHPCS and PHPMD PSR2 validation.
|
||||||
|
|
||||||
|
## Submitting changes
|
||||||
|
When submitting a pull request, it is important to make sure to complete the following:
|
||||||
|
- [ ] Add a descriptive header that explains in a single sentence what problem the PR solves.
|
||||||
|
- [ ] Add a detailed description with animated screen-grab GIFs visualizing how it works.
|
||||||
|
- [ ] Explain why you think it should be implemented one way vs. another, highlight performance improvements, etc.
|
||||||
|
|
||||||
|
## Coding conventions
|
||||||
|
Start reading our code and you'll get the hang of it. We optimize for readability:
|
||||||
|
- indent using four spaces (soft tabs)
|
||||||
|
- use Blade for all views
|
||||||
|
- avoid logic in views, put it in controllers or service classes
|
||||||
|
- ALWAYS put spaces after list items and method parameters (`[1, 2, 3]`, not `[1,2,3]`), around operators (`x += 1`, not `x+=1`), and around hash arrows.
|
||||||
|
- this is open source software. Consider the people who will read your code, and make it look nice for them. It's sort of like driving a car: Perhaps you love doing donuts when you're alone, but with passengers the goal is to make the ride as smooth as possible.
|
||||||
|
- emphasis readability of code over patterns to reduce mental debt
|
||||||
|
- always add an empty line around structures (if statements, loops, etc.)
|
||||||
|
|
||||||
|
Thanks!
|
||||||
|
Mike Bronner, GeneaLabs
|
||||||
124
readme.md
124
readme.md
@@ -1,5 +1,16 @@
|
|||||||
# Sign In With Apple for Laravel
|
# Sign In With Apple for Laravel
|
||||||
|
|
||||||
|
## Supporting This Package
|
||||||
|
|
||||||
|
This is an MIT-licensed open source project with its ongoing development made possible by the support of the community. If you'd like to support this, and our other packages, please consider sponsoring us via the button above.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- PHP 7.2+
|
||||||
|
- Laravel 6.2+
|
||||||
|
- Socialite 4.2+
|
||||||
|
- Apple Developer Subscription
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -8,19 +19,86 @@ composer require genealabs/laravel-sign-in-with-apple
|
|||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
1. Create your app's client secret:
|
1. Create an `App ID` for your website (https://developer.apple.com/account/resources/identifiers/list/bundleId) with the following details:
|
||||||
|
- Platform: iOS, tvOS, watchOS (I'm unsure if either choice has an effect for web apps)
|
||||||
|
- Description: (something like "example.com app id")
|
||||||
|
- Bundle ID (Explicit): com.example.id (or something similar)
|
||||||
|
- Check "Sign In With Apple"
|
||||||
|
2. Create a `Service ID` for your website (https://developer.apple.com/account/resources/identifiers/list/serviceId) with the following details:
|
||||||
|
- Description: (something like "example.com service id")
|
||||||
|
- Identifier: com.example.service (or something similar)
|
||||||
|
- Check "Sign In With Apple"
|
||||||
|
- Configure "Sign In With Apple":
|
||||||
|
- Primary App Id: (select the primary app id created in step 1)
|
||||||
|
- Web Domain: example.com (the domain of your web site)
|
||||||
|
- Return URLs: https://example.com/apple-signin (the route pointing to the callback method in your controller)
|
||||||
|
- Click "Save".
|
||||||
|
- Click the "Edit" button to edit the details of the "Sign In With Apple"
|
||||||
|
configuration we just created.
|
||||||
|
- If you haven't verified the domain yet, download the verification file,
|
||||||
|
upload it to https://example.com/.well-known/apple-developer-domain-association.txt, and then click the "Verify"
|
||||||
|
button.
|
||||||
|
3. Create a `Private Key` for your website (https://developer.apple.com/account/resources/authkeys/list) with the following details:
|
||||||
|
- Key Name:
|
||||||
|
- Check "Sign In With Apple"
|
||||||
|
- Configure "Sign In With Apple":
|
||||||
|
- Primary App ID: (select the primary app id created in step 1)
|
||||||
|
- Click "Save"
|
||||||
|
- Click "Continue"
|
||||||
|
- Click "Register"
|
||||||
|
- Click "Download"
|
||||||
|
- Rename the downloaded file to `key.txt`
|
||||||
|
4. Create your app's client secret:
|
||||||
|
- Install the JWT Gem:
|
||||||
|
```sh
|
||||||
|
sudo gem install jwt
|
||||||
|
```
|
||||||
|
|
||||||
```sh
|
- Create a temporary file to process the private key:
|
||||||
TBA
|
```ruby
|
||||||
```
|
require 'jwt'
|
||||||
|
|
||||||
1. Set the necessary environment variables in your `.env` file:
|
key_file = 'key.txt'
|
||||||
|
team_id = ''
|
||||||
|
client_id = ''
|
||||||
|
key_id = ''
|
||||||
|
|
||||||
|
ecdsa_key = OpenSSL::PKey::EC.new IO.read key_file
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'kid' => key_id
|
||||||
|
}
|
||||||
|
|
||||||
|
claims = {
|
||||||
|
'iss' => team_id,
|
||||||
|
'iat' => Time.now.to_i,
|
||||||
|
'exp' => Time.now.to_i + 86400*180,
|
||||||
|
'aud' => 'https://appleid.apple.com',
|
||||||
|
'sub' => client_id,
|
||||||
|
}
|
||||||
|
|
||||||
|
token = JWT.encode claims, ecdsa_key, 'ES256', headers
|
||||||
|
|
||||||
|
puts token
|
||||||
|
```
|
||||||
|
|
||||||
|
- Fill in the following fields:
|
||||||
|
- `team_id`: This can be found on the top-right corner when logged into
|
||||||
|
your Apple Developer account, right under your name.
|
||||||
|
- `client_id`: This is the identifier from the Service Id created in step
|
||||||
|
2 above, for example com.example.service
|
||||||
|
- `key_id`: This is the identifier of the private key created in step 3
|
||||||
|
above.
|
||||||
|
- Save the file and run it from the terminal. It will spit out a JWT which is
|
||||||
|
your client secret, which you will need to add to your `.env` file in the
|
||||||
|
next step.
|
||||||
|
5. Set the necessary environment variables in your `.env` file:
|
||||||
|
|
||||||
```env
|
```env
|
||||||
SIGN_IN_WITH_APPLE_LOGIN="/apple/login/controller/login/action"
|
SIGN_IN_WITH_APPLE_LOGIN="/apple/login/controller/login/action"
|
||||||
SIGN_IN_WITH_APPLE_REDIRECT="/apple/login/controller/callback/action"
|
SIGN_IN_WITH_APPLE_REDIRECT="/apple/login/controller/callback/action"
|
||||||
SIGN_IN_WITH_APPLE_CLIENT_ID="your app's service id as registered with Apple"
|
SIGN_IN_WITH_APPLE_CLIENT_ID="your app's service id as registered with Apple"
|
||||||
SIGN_IN_WITH_APPLE_CLIENT_SECRET="your app's client secret as calculated"
|
SIGN_IN_WITH_APPLE_CLIENT_SECRET="your app's client secret as calculated in step 4"
|
||||||
```
|
```
|
||||||
|
|
||||||
## Implementation
|
## Implementation
|
||||||
@@ -74,3 +152,37 @@ class AppleSigninController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
#### Credits
|
||||||
|
1. https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple
|
||||||
|
2. https://developer.apple.com/sign-in-with-apple/get-started
|
||||||
|
|
||||||
|
----------
|
||||||
|
|
||||||
|
## Commitment to Quality
|
||||||
|
During package development I try as best as possible to embrace good design and development practices, to help ensure that this package is as good as it can
|
||||||
|
be. My checklist for package development includes:
|
||||||
|
|
||||||
|
- ✅ Achieve as close to 100% code coverage as possible using unit tests.
|
||||||
|
- ✅ Eliminate any issues identified by SensioLabs Insight and Scrutinizer.
|
||||||
|
- ✅ Be fully PSR1, PSR2, and PSR4 compliant.
|
||||||
|
- ✅ Include comprehensive documentation in README.md.
|
||||||
|
- ✅ Provide an up-to-date CHANGELOG.md which adheres to the format outlined
|
||||||
|
at <http://keepachangelog.com>.
|
||||||
|
- ✅ Have no PHPMD or PHPCS warnings throughout all code.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
Please observe and respect all aspects of the included Code of Conduct <https://github.com/GeneaLabs/nova-map-marker-field/blob/master/CODE_OF_CONDUCT.md>.
|
||||||
|
|
||||||
|
### Reporting Issues
|
||||||
|
When reporting issues, please fill out the included template as completely as
|
||||||
|
possible. Incomplete issues may be ignored or closed if there is not enough
|
||||||
|
information included to be actionable.
|
||||||
|
|
||||||
|
### Submitting Pull Requests
|
||||||
|
Please review the Contribution Guidelines <https://github.com/GeneaLabs/nova-map-marker-field/blob/master/CONTRIBUTING.md>. Only PRs that meet all criterium will be accepted.
|
||||||
|
|
||||||
|
## If you ❤️ open-source software, give the repos you use a ⭐️.
|
||||||
|
We have included the awesome `symfony/thanks` composer package as a dev dependency. Let your OS package maintainers know you appreciate them by starring the packages you use. Simply run `composer thanks` after installing this package. (And not to worry, since it's a dev-dependency it won't be installed in your live environment.)
|
||||||
|
|||||||
Reference in New Issue
Block a user