Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(oauth-apple): support Sign in with Apple as a documented OmniAuth provider #1347

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ group :development, :test do
gem 'omniauth-facebook'
gem 'omniauth-github'
gem 'omniauth-google-oauth2'
gem 'omniauth-apple'
gem 'rack-cors'
gem 'thor'

Expand Down
3 changes: 2 additions & 1 deletion devise_token_auth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ Gem::Specification.new do |s|
s.required_ruby_version = ">= 2.2.0"

s.add_dependency 'rails', '>= 4.2.0', '< 6.1'
s.add_dependency 'sprockets', '3.7.2' # FIXME: breaking changes in 4.0.0
s.add_dependency 'devise', '> 3.5.2', '< 5'
s.add_dependency 'bcrypt', '~> 3.0'

s.add_development_dependency 'appraisal'
s.add_development_dependency 'sqlite3', '~> 1.3.6'
s.add_development_dependency 'sqlite3', '~> 1.4'
s.add_development_dependency 'pg'
s.add_development_dependency 'mysql2'
s.add_development_dependency 'mongoid', '>= 4', '< 8'
Expand Down
6 changes: 4 additions & 2 deletions docs/config/omniauth.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

If you wish to use omniauth authentication, add all of your desired authentication provider gems to your `Gemfile`.

**OmniAuth example using github, facebook, and google**:
**OmniAuth example using GitHub, Facebook, Google, and Apple**:
~~~ruby
gem 'omniauth-github'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-apple'
~~~

Then run `bundle install`.
Expand All @@ -21,13 +22,14 @@ In `config/initializers/omniauth.rb`, add the settings for each of your provider

These settings must be obtained from the providers themselves.

**Example using github, facebook, and google**:
**Example using Github, Facebook, Google, and Apple**:
~~~ruby
# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
provider :apple, ENV['APPLE_CLIENT_ID'], '', { scope: 'email name', team_id: ENV['APPLE_TEAM_ID'], key_id: ENV['APPLE_KEY'], pem: ENV['APPLE_PEM'] }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This provider does not accept a secret directly, rather it uses a p8 PEM certificate to generate JWT authorization tokens on the fly for provider handshake.

end
~~~

Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_4_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_4_2_mongoid_5.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_1_mongoid_6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_1_mongoid_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_2_mongoid_6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
1 change: 1 addition & 0 deletions gemfiles/rails_5_2_mongoid_7.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group :development, :test do
gem "omniauth-facebook", git: "https://github.com/mkdynamic/omniauth-facebook"
gem "omniauth-github", git: "https://github.com/intridea/omniauth-github"
gem "omniauth-google-oauth2", git: "https://github.com/zquestz/omniauth-google-oauth2"
gem 'omniauth-apple'
gem "rack-cors", require: "rack/cors"
gem "thor"
gem "database_cleaner"
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/initializers/figaro.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# frozen_string_literal: true

#Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET")
#Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET", "APPLE_CLIENT_ID", "APPLE_TEAM_ID", "APPLE_KEY", "APPLE_PEM")
1 change: 1 addition & 0 deletions test/dummy/config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
provider :apple, ENV['APPLE_CLIENT_ID'], '', { scope: 'email name', team_id: ENV['APPLE_TEAM_ID'], key_id: ENV['APPLE_KEY'], pem: ENV['APPLE_PEM'] }
provider :developer,
fields: [:first_name, :last_name],
uid_field: :last_name
Expand Down