solidus_social 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +3 -0
- data/.github/dependabot.yml +7 -0
- data/Gemfile +8 -2
- data/README.md +44 -43
- data/app/controllers/spree/omniauth_callbacks_controller.rb +1 -1
- data/app/core/spree/permission_sets/authentication_method_display.rb +11 -0
- data/app/core/spree/permission_sets/authentication_method_management.rb +11 -0
- data/app/overrides/admin_configuration_decorator.rb +7 -2
- data/app/views/spree/admin/authentication_methods/edit.html.erb +3 -1
- data/app/views/spree/admin/authentication_methods/index.html.erb +11 -7
- data/app/views/spree/admin/authentication_methods/new.html.erb +3 -1
- data/app/views/spree/shared/_social.html.erb +7 -3
- data/config/locales/es-MX.yml +5 -1
- data/config/locales/es.yml +30 -0
- data/lib/generators/solidus_social/install/templates/config/initializers/solidus_social.rb +1 -10
- data/lib/solidus_social/engine.rb +3 -8
- data/{app/models/spree → lib/solidus_social}/social_configuration.rb +2 -0
- data/lib/solidus_social/version.rb +1 -1
- data/solidus_social.gemspec +4 -5
- data/spec/controllers/spree/omniauth_callbacks_controller_spec.rb +17 -17
- data/spec/features/spree/admin/authentication_methods_configuration_spec.rb +2 -2
- data/spec/features/spree/sign_in_spec.rb +80 -10
- data/spec/lib/spree/social_config_spec.rb +1 -1
- data/spec/models/spree/authentication_method_spec.rb +0 -2
- metadata +18 -29
- data/.github/stale.yml +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1877be6601ecd77f99eb28f6bb0ddf0b6b702cb80a7ca163f5472f5a34a3937f
|
4
|
+
data.tar.gz: 9ac2438fad599892a90abde85e1d20bed50641e0a5661c906e8950436fa52041
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3c7b24eee76fbe4a361c6da83ad7e3f4d88e78b4686db243b6ec995a48454929ef9bb00e92d987994a0b7bbb6cae1e10598f75cb10a82ec30225c5c16208c22
|
7
|
+
data.tar.gz: e96864533c0a6d567afef96682601126ce50591f99d179205e9e8420ab6942b0e58ffb9e2b39eccdbc7de119cbbc182cb3366d290e025e42c051c15298b70e85
|
data/.circleci/config.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
3
|
orbs:
|
4
|
+
browser-tools: circleci/browser-tools@1.4
|
4
5
|
# Always take the latest version of the orb, this allows us to
|
5
6
|
# run specs against Solidus supported versions only without the need
|
6
7
|
# to change this configuration every time a Solidus version is released
|
@@ -11,10 +12,12 @@ jobs:
|
|
11
12
|
run-specs-with-postgres:
|
12
13
|
executor: solidusio_extensions/postgres
|
13
14
|
steps:
|
15
|
+
- browser-tools/install-browser-tools
|
14
16
|
- solidusio_extensions/run-tests
|
15
17
|
run-specs-with-mysql:
|
16
18
|
executor: solidusio_extensions/mysql
|
17
19
|
steps:
|
20
|
+
- browser-tools/install-browser-tools
|
18
21
|
- solidusio_extensions/run-tests
|
19
22
|
|
20
23
|
workflows:
|
data/Gemfile
CHANGED
@@ -4,7 +4,13 @@ source 'https://rubygems.org'
|
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
6
|
branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
|
7
|
-
|
7
|
+
solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
|
8
|
+
%w[solidusio/solidus solidusio/solidus_frontend]
|
9
|
+
else
|
10
|
+
%w[solidusio/solidus] * 2
|
11
|
+
end
|
12
|
+
gem 'solidus', github: solidus_git, branch: branch
|
13
|
+
gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
|
8
14
|
|
9
15
|
# Needed to help Bundler figure out how to resolve dependencies,
|
10
16
|
# otherwise it takes forever to resolve them.
|
@@ -27,4 +33,4 @@ gemspec
|
|
27
33
|
|
28
34
|
# Use a local Gemfile to include development dependencies that might not be
|
29
35
|
# relevant for the project or for other contributors, e.g.: `gem 'pry-debug'`.
|
30
|
-
eval_gemfile 'Gemfile-local' if File.exist? 'Gemfile-local'
|
36
|
+
send :eval_gemfile, 'Gemfile-local' if File.exist? 'Gemfile-local'
|
data/README.md
CHANGED
@@ -5,8 +5,8 @@ SolidusSocial
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/solidusio-contrib/solidus_social/badges/gpa.svg)](https://codeclimate.com/github/solidusio-contrib/solidus_social)
|
6
6
|
|
7
7
|
Social login support for Solidus. Solidus Social handles authorization, account
|
8
|
-
creation and association through third-party services.
|
9
|
-
Facebook, Github
|
8
|
+
creation and association through third-party services.
|
9
|
+
Currently Facebook, Github and Google OAuth2 are available out of the box.
|
10
10
|
|
11
11
|
Installation
|
12
12
|
------------
|
@@ -44,7 +44,7 @@ Click "New Authentication Method" and choose one of your configured providers.
|
|
44
44
|
Registering Your Application
|
45
45
|
----------------------------
|
46
46
|
|
47
|
-
Facebook,
|
47
|
+
Facebook, Github and Google OAuth2 are supported out of the
|
48
48
|
box but, you will need to register your application with each of the sites you
|
49
49
|
want to use.
|
50
50
|
|
@@ -64,20 +64,6 @@ Make sure you specifity the right IP address.
|
|
64
64
|
`http://your-site.com` for production
|
65
65
|
- Site domain: `yourhostname.local` and `your-site.com` respectively
|
66
66
|
|
67
|
-
### Twitter
|
68
|
-
|
69
|
-
[Twitter / Application Management / Create an application][3]
|
70
|
-
|
71
|
-
1. Fill in the name and description.
|
72
|
-
2. Fill in the rest of the details:
|
73
|
-
- Application Website: `http://yourhostname.local:3000` for development and
|
74
|
-
`http://your-site.com` for production
|
75
|
-
- Application Type: "Browser"
|
76
|
-
- Callback URL: `http://yourhostname.local:3000` for development and
|
77
|
-
`http://your-site.com` for production
|
78
|
-
- Default Access Type: "Read & Write"
|
79
|
-
6. Save the application.
|
80
|
-
|
81
67
|
### Github
|
82
68
|
|
83
69
|
[Github / Applications / Register a new OAuth application][4]
|
@@ -90,18 +76,6 @@ Make sure you specifity the right IP address.
|
|
90
76
|
`http://your-site.com` for production
|
91
77
|
4. Click Create.
|
92
78
|
|
93
|
-
### Amazon
|
94
|
-
|
95
|
-
[Amazon / App Console / Register a new OAuth application][10]
|
96
|
-
|
97
|
-
1. Register New Application.
|
98
|
-
2. Name the Application, provide description and URL for Privacy Policy.
|
99
|
-
3. Click Save.
|
100
|
-
4. Add Your site under Web Settings > Allowed Return URLs (example:
|
101
|
-
`http://localhost:3000/users/auth/amazon/callback`)
|
102
|
-
|
103
|
-
> The app console is available at [https://login.amazon.com/manageApps](https://login.amazon.com/manageApps)
|
104
|
-
|
105
79
|
### Google OAuth2
|
106
80
|
[Google / APIs / Credentials/ Create Credential](https://console.developers.google.com/)
|
107
81
|
|
@@ -140,11 +114,40 @@ strategy][12] for them. (If there isn't, you can [write one][13].)
|
|
140
114
|
your LinkedIn link.
|
141
115
|
- Include in your CSS a definition for `.icon-spree-linkedin-circled` and an
|
142
116
|
embedded icon font for LinkedIn from [Fontello][14] (the way existing
|
143
|
-
icons for Facebook
|
117
|
+
icons for Facebook etc are implemented). You can also override
|
144
118
|
CSS classes for other providers, `.icon-spree-<provider>-circled`, to use
|
145
119
|
different font icons or classic background images, without having to
|
146
120
|
override views.
|
147
121
|
|
122
|
+
#### Apple Id Example
|
123
|
+
|
124
|
+
1. Add `gem "omniauth-apple"` to your Gemfile and run `bundle install`.
|
125
|
+
2. In `config/initializers/solidus_social.rb` add and initialize a new provider
|
126
|
+
for SolidusSocial:
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
|
130
|
+
config.providers = {
|
131
|
+
apple: {
|
132
|
+
icon: 'fa-apple',
|
133
|
+
title: 'Apple'
|
134
|
+
},
|
135
|
+
# More providers here
|
136
|
+
```
|
137
|
+
add its configuration after `SolidusSocial.init_providers` line:
|
138
|
+
```ruby
|
139
|
+
|
140
|
+
Devise.setup do |config|
|
141
|
+
# The configuration key has to match your omniauth strategy.
|
142
|
+
config.omniauth :apple, ENV['APPLE_CLIENT_ID'], '',
|
143
|
+
scope: 'email',
|
144
|
+
team_id: ENV['APPLE_TEAM_ID'],
|
145
|
+
key_id: ENV['APPLE_KEY_ID'],
|
146
|
+
pem: ENV['APPLE_PRIVATE_KEY'].gsub('\n', "\n")
|
147
|
+
end
|
148
|
+
```
|
149
|
+
Notice: APPLE_PRIVATE_KEY should consist from one-line p8-file content, like this `'\n-----BEGIN PRIVATE KEY-----\nsecret\n-----END PRIVATE KEY-----\n'`
|
150
|
+
|
148
151
|
Documentation
|
149
152
|
-------------
|
150
153
|
|
@@ -188,16 +191,14 @@ Copyright (c) 2014 [John Dyer][7] and [contributors][8], released under the [New
|
|
188
191
|
|
189
192
|
[1]: https://github.com/spree/spree
|
190
193
|
[2]: https://developers.facebook.com/apps/?action=create
|
191
|
-
[3]: https://
|
192
|
-
[4]:
|
193
|
-
[5]:
|
194
|
-
[6]: https://github.com/
|
195
|
-
[7]: https://github.com/
|
196
|
-
[8]: https://github.com/solidusio-contrib/solidus_social/
|
197
|
-
[9]: https://github.com/solidusio-contrib/solidus_social/blob/master/
|
198
|
-
[10]: https://
|
199
|
-
[11]: https://github.com/
|
200
|
-
[12]:
|
201
|
-
[13]:
|
202
|
-
[14]: http://fontello.com/
|
203
|
-
[15]: http://www.rubydoc.info/github/solidusio-contrib/solidus_social/
|
194
|
+
[3]: https://github.com/settings/applications/new
|
195
|
+
[4]: http://www.fsf.org/licensing/essays/free-sw.html
|
196
|
+
[5]: https://github.com/solidusio-contrib/solidus_social/issues
|
197
|
+
[6]: https://github.com/LBRapid
|
198
|
+
[7]: https://github.com/solidusio-contrib/solidus_social/graphs/contributors
|
199
|
+
[8]: https://github.com/solidusio-contrib/solidus_social/blob/master/LICENSE
|
200
|
+
[9]: https://github.com/solidusio-contrib/solidus_social/blob/master/CONTRIBUTING.md
|
201
|
+
[10]: https://github.com/intridea/omniauth/wiki/List-of-Strategies
|
202
|
+
[11]: https://github.com/intridea/omniauth/wiki/Strategy-Contribution-Guide
|
203
|
+
[12]: http://fontello.com/
|
204
|
+
[13]: http://www.rubydoc.info/github/solidusio-contrib/solidus_social/
|
@@ -62,7 +62,7 @@ class Spree::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def passthru
|
65
|
-
render file: "#{Rails.root}/public/404", formats: [:html], status: :not_found, layout: false
|
65
|
+
render file: "#{Rails.root}/public/404.html", formats: [:html], status: :not_found, layout: false
|
66
66
|
end
|
67
67
|
|
68
68
|
def auth_hash
|
@@ -3,5 +3,10 @@
|
|
3
3
|
Deface::Override.new(virtual_path: 'spree/admin/shared/_configuration_menu',
|
4
4
|
name: 'add_social_providers_link_configuration_menu',
|
5
5
|
insert_bottom: '[data-hook="admin_configurations_sidebar_menu"]',
|
6
|
-
|
7
|
-
|
6
|
+
disabled: false) do
|
7
|
+
<<-HTML
|
8
|
+
<% if can? :admin, Spree::AuthenticationMethod %>
|
9
|
+
<%= configurations_sidebar_menu_item I18n.t("spree.social_authentication_methods"), spree.admin_authentication_methods_path %>
|
10
|
+
<% end %>
|
11
|
+
HTML
|
12
|
+
end
|
@@ -13,6 +13,8 @@
|
|
13
13
|
<%= form_for [:admin, @authentication_method] do |f| %>
|
14
14
|
<fieldset class="no-border-top">
|
15
15
|
<%= render 'form', f: f %>
|
16
|
-
|
16
|
+
<% if can? :manage, Spree::AuthenticationMethod %>
|
17
|
+
<%= render 'spree/admin/shared/edit_resource_links' %>
|
18
|
+
<% end %>
|
17
19
|
</fieldset>
|
18
20
|
<% end %>
|
@@ -5,11 +5,13 @@
|
|
5
5
|
<% end %>
|
6
6
|
|
7
7
|
<% content_for :page_actions do %>
|
8
|
-
|
9
|
-
<
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
<% if can? :manage, Spree::AuthenticationMethod %>
|
9
|
+
<ul class="actions inline-menu">
|
10
|
+
<li>
|
11
|
+
<%= link_to I18n.t('spree.new_social_method'), new_object_url, id: 'admin_new_slide_link' %>
|
12
|
+
</li>
|
13
|
+
</ul>
|
14
|
+
<% end %>
|
13
15
|
<% end %>
|
14
16
|
|
15
17
|
<% if @authentication_methods.any? %>
|
@@ -39,8 +41,10 @@
|
|
39
41
|
<td class="align-center"><%= method.environment.to_s.titleize %></td>
|
40
42
|
<td class="align-center"><%= method.active ? I18n.t('spree.yes') : I18n.t('spree.no') %></td>
|
41
43
|
<td class="actions">
|
42
|
-
|
43
|
-
|
44
|
+
<% if can? :manage, Spree::AuthenticationMethod %>
|
45
|
+
<%= link_to_edit method, no_text: true %>
|
46
|
+
<%= link_to_delete method, no_text: true %>
|
47
|
+
<% end %>
|
44
48
|
</td>
|
45
49
|
</tr>
|
46
50
|
<% end %>
|
@@ -13,6 +13,8 @@
|
|
13
13
|
<%= form_for [:admin, @authentication_method] do |f| %>
|
14
14
|
<fieldset class="no-border-top">
|
15
15
|
<%= render 'form', f: f %>
|
16
|
-
|
16
|
+
<% if can? :manage, Spree::AuthenticationMethod %>
|
17
|
+
<%= render 'spree/admin/shared/new_resource_links' %>
|
18
|
+
<% end %>
|
17
19
|
</fieldset>
|
18
20
|
<% end %>
|
@@ -4,8 +4,12 @@
|
|
4
4
|
<% end %>
|
5
5
|
|
6
6
|
<% Spree::AuthenticationMethod.available_for(spree_current_user).each do |method| %>
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
<% if method.active %>
|
8
|
+
<%= form_tag(spree.send("spree_user_#{method.provider}_omniauth_authorize_path", r: rand), method: 'post') do %>
|
9
|
+
<%= button_tag(type: 'submit', title: t('spree.sign_in_with', provider: method.provider)) do %>
|
10
|
+
<%= content_tag(:i, '', class: "icon-spree-#{method.provider.dasherize}-circled") %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
10
14
|
<% end %>
|
11
15
|
</div>
|
data/config/locales/es-MX.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
---
|
2
2
|
es-MX:
|
3
|
+
authentications:
|
4
|
+
spree:
|
5
|
+
destroy: Método de autenticación eliminado
|
3
6
|
devise:
|
4
7
|
omniauth_callbacks:
|
5
|
-
success: "Estás sesión con tu cuenta de %{kind}."
|
8
|
+
success: "Estás en sesión con tu cuenta de %{kind}."
|
6
9
|
spree:
|
7
10
|
user_was_not_valid: "El usuario no fue válido."
|
8
11
|
add_another_service: 'Añadir otro servicio para inicio de sesión:'
|
@@ -24,3 +27,4 @@ es-MX:
|
|
24
27
|
please_confirm_your_email: 'Por favor confirme su email para continuar'
|
25
28
|
sign_in_with: 'Autenticado con %{provider}'
|
26
29
|
you_have_signed_in_with_these_services: "Has iniciado sesión con estos servicios"
|
30
|
+
environment: Ambiente
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
es:
|
3
|
+
authentications:
|
4
|
+
spree:
|
5
|
+
destroy: Método de autenticación eliminado
|
6
|
+
devise:
|
7
|
+
omniauth_callbacks:
|
8
|
+
success: "Estás en sesión con tu cuenta de %{kind}."
|
9
|
+
spree:
|
10
|
+
user_was_not_valid: "El usuario no fue válido."
|
11
|
+
add_another_service: 'Añadir otro servicio para inicio de sesión:'
|
12
|
+
authentications:
|
13
|
+
destroy: 'Método de autenticación eliminado exitosamente.'
|
14
|
+
back_to_authentication_methods_list: "Volver a la lista de métodos de autenticación"
|
15
|
+
edit_social_method: 'Editando metodo de autenticación'
|
16
|
+
new_social_method: 'Nuevo método de autenticación'
|
17
|
+
no_authentication_methods_found: "No se encuentran ningún método de autenticación"
|
18
|
+
one_more_step: 'Un paso más para completar tu registro desde %{kind}'
|
19
|
+
remove_authentication_option_confirmation: '¿Está seguro que quiere eliminar este método de autenticación?'
|
20
|
+
sign_into_account: 'Puedes iniciar sesión usando:'
|
21
|
+
sign_in_through_one_of_these_services: 'Iniciar sesión a través de uno de estos servicios:'
|
22
|
+
social_api_key: 'API Clave'
|
23
|
+
social_api_secret: 'API Secreto'
|
24
|
+
social_authentication_methods: 'Métodos de autenticación'
|
25
|
+
social_authentication_methods_description: 'Configurar métodos de autenticación de OAuth'
|
26
|
+
social_provider: 'Proveedor social'
|
27
|
+
please_confirm_your_email: 'Por favor confirme su email para continuar'
|
28
|
+
sign_in_with: 'Autenticado con %{provider}'
|
29
|
+
you_have_signed_in_with_these_services: "Has iniciado sesión con estos servicios"
|
30
|
+
environment: Ambiente
|
@@ -18,10 +18,6 @@ Spree::SocialConfig.configure do |config|
|
|
18
18
|
api_key: ENV['FACEBOOK_API_KEY'],
|
19
19
|
api_secret: ENV['FACEBOOK_API_SECRET'],
|
20
20
|
},
|
21
|
-
twitter: {
|
22
|
-
api_key: ENV['TWITTER_API_KEY'],
|
23
|
-
api_secret: ENV['TWITTER_API_SECRET'],
|
24
|
-
},
|
25
21
|
github: {
|
26
22
|
api_key: ENV['GITHUB_API_KEY'],
|
27
23
|
api_secret: ENV['GITHUB_API_SECRET'],
|
@@ -29,10 +25,6 @@ Spree::SocialConfig.configure do |config|
|
|
29
25
|
google_oauth2: {
|
30
26
|
api_key: ENV['GOOGLE_OAUTH2_API_KEY'],
|
31
27
|
api_secret: ENV['GOOGLE_OAUTH2_API_SECRET'],
|
32
|
-
},
|
33
|
-
amazon: {
|
34
|
-
api_key: ENV['AMAZON_API_KEY'],
|
35
|
-
api_secret: ENV['AMAZON_API_SECRET'],
|
36
28
|
}
|
37
29
|
}
|
38
30
|
end
|
@@ -44,7 +36,6 @@ OmniAuth.logger.progname = 'omniauth'
|
|
44
36
|
|
45
37
|
OmniAuth.config.on_failure = proc do |env|
|
46
38
|
env['devise.mapping'] = Devise.mappings[Spree.user_class.table_name.singularize.to_sym]
|
47
|
-
|
48
|
-
controller_klass = ActiveSupport::Inflector.constantize("#{controller_name}Controller")
|
39
|
+
controller_klass = ActiveSupport::Inflector.constantize("Spree::OmniauthCallbacksController")
|
49
40
|
controller_klass.action(:failure).call(env)
|
50
41
|
end
|
@@ -1,18 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'omniauth-twitter'
|
4
3
|
require 'omniauth-facebook'
|
5
4
|
require 'omniauth-github'
|
6
5
|
require 'omniauth-google-oauth2'
|
7
|
-
require 'omniauth
|
6
|
+
require 'omniauth/rails_csrf_protection'
|
8
7
|
require 'deface'
|
9
|
-
require 'coffee_script'
|
10
8
|
require 'spree/core'
|
9
|
+
require 'solidus_social/social_configuration'
|
11
10
|
require 'solidus_social/facebook_omniauth_strategy_ext'
|
12
11
|
|
13
12
|
module SolidusSocial
|
14
13
|
class Engine < Rails::Engine
|
15
|
-
include SolidusSupport::EngineExtensions
|
14
|
+
include SolidusSupport::EngineExtensions
|
16
15
|
|
17
16
|
isolate_namespace ::Spree
|
18
17
|
|
@@ -27,10 +26,6 @@ module SolidusSocial
|
|
27
26
|
"app/decorators/models/solidus_social/spree/user_decorator.rb"
|
28
27
|
).to_s
|
29
28
|
|
30
|
-
initializer 'solidus_social.environment', before: 'spree.environment' do
|
31
|
-
::Spree::SocialConfig = ::Spree::SocialConfiguration.new
|
32
|
-
end
|
33
|
-
|
34
29
|
initializer 'solidus_social.decorate_spree_user' do |app|
|
35
30
|
next unless app.respond_to?(:reloader)
|
36
31
|
|
data/solidus_social.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.metadata['source_code_uri'] = 'https://github.com/solidusio-contrib/solidus_social'
|
18
18
|
spec.metadata['changelog_uri'] = 'https://github.com/solidusio-contrib/solidus_social/blob/master/CHANGELOG.md'
|
19
19
|
|
20
|
-
spec.required_ruby_version =
|
20
|
+
spec.required_ruby_version = '>= 2.4'
|
21
21
|
|
22
22
|
# Specify which files should be added to the gem when it is released.
|
23
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -31,14 +31,13 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency 'deface'
|
32
32
|
spec.add_dependency 'oa-core'
|
33
33
|
spec.add_dependency 'omniauth'
|
34
|
-
spec.add_dependency 'omniauth-amazon'
|
35
34
|
spec.add_dependency 'omniauth-facebook'
|
36
35
|
spec.add_dependency 'omniauth-github'
|
37
36
|
spec.add_dependency 'omniauth-google-oauth2'
|
38
|
-
spec.add_dependency 'omniauth-
|
37
|
+
spec.add_dependency 'omniauth-rails_csrf_protection'
|
39
38
|
spec.add_dependency 'solidus_auth_devise'
|
40
|
-
spec.add_dependency 'solidus_core', ['>= 2.0.0', '<
|
41
|
-
spec.add_dependency 'solidus_support', '~> 0.
|
39
|
+
spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
|
40
|
+
spec.add_dependency 'solidus_support', '~> 0.5'
|
42
41
|
|
43
42
|
spec.add_development_dependency 'solidus_dev_support'
|
44
43
|
end
|
@@ -18,17 +18,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
18
18
|
|
19
19
|
it 'redirects properly' do
|
20
20
|
expect(controller).to receive(:redirect_back_or_default)
|
21
|
-
controller.
|
21
|
+
controller.github
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'displays an error message' do
|
25
|
-
controller.
|
25
|
+
controller.github
|
26
26
|
expect(flash[:error]).not_to be_blank
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'does not attempt authentication' do
|
30
30
|
expect(controller).not_to receive(:sign_in_and_redirect)
|
31
|
-
controller.
|
31
|
+
controller.github
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -37,7 +37,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
37
37
|
|
38
38
|
it 'associates the order with the user' do
|
39
39
|
expect(order).to receive(:associate_user!).with(user)
|
40
|
-
controller.
|
40
|
+
controller.github
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -64,17 +64,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
64
64
|
|
65
65
|
it 'does not need to create the user_authentication' do
|
66
66
|
expect(user.user_authentications).not_to receive(:create!)
|
67
|
-
controller.
|
67
|
+
controller.github
|
68
68
|
end
|
69
69
|
|
70
70
|
it 'sets the flash notice' do
|
71
|
-
controller.
|
71
|
+
controller.github
|
72
72
|
expect(flash[:notice]).not_to be_blank
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'authenticates as that user' do
|
76
76
|
expect(controller).to receive(:sign_in_and_redirect)
|
77
|
-
controller.
|
77
|
+
controller.github
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -86,17 +86,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
86
86
|
it 'creates a new user_authentication' do
|
87
87
|
expect(user).to receive(:apply_omniauth)
|
88
88
|
expect(user).to receive(:save!)
|
89
|
-
controller.
|
89
|
+
controller.github
|
90
90
|
end
|
91
91
|
|
92
92
|
it 'sets the flash notice' do
|
93
|
-
controller.
|
93
|
+
controller.github
|
94
94
|
expect(flash[:notice]).not_to be_blank
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'redirects properly' do
|
98
98
|
expect(controller).to receive(:redirect_back_or_default)
|
99
|
-
controller.
|
99
|
+
controller.github
|
100
100
|
end
|
101
101
|
|
102
102
|
it_behaves_like 'associate_order'
|
@@ -119,17 +119,17 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
119
119
|
|
120
120
|
it 'does not need to create the user_authentication' do
|
121
121
|
expect(user.user_authentications).not_to receive(:create!)
|
122
|
-
controller.
|
122
|
+
controller.github
|
123
123
|
end
|
124
124
|
|
125
125
|
it 'does not create a new user account' do
|
126
126
|
expect(Spree::User).not_to receive :new
|
127
|
-
controller.
|
127
|
+
controller.github
|
128
128
|
end
|
129
129
|
|
130
130
|
it 'authenticates as that user' do
|
131
131
|
expect(controller).to receive(:sign_in_and_redirect).with(:spree_user, user)
|
132
|
-
controller.
|
132
|
+
controller.github
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
@@ -144,7 +144,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
144
144
|
context "email doesn't belongs to anyone" do
|
145
145
|
it 'creates a new user' do
|
146
146
|
expect(controller).to receive(:sign_in_and_redirect)
|
147
|
-
expect { controller.
|
147
|
+
expect { controller.github }.to change(Spree::User, :count).by(1)
|
148
148
|
end
|
149
149
|
|
150
150
|
context 'when `Spree.user_class` has changed' do
|
@@ -170,7 +170,7 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
170
170
|
expect(Spree::User).not_to receive :new
|
171
171
|
expect_any_instance_of(Spree::User).not_to receive :save
|
172
172
|
|
173
|
-
expect { controller.
|
173
|
+
expect { controller.github }
|
174
174
|
.to change(Spree::LegacyUser, :count).by(1)
|
175
175
|
end
|
176
176
|
end
|
@@ -180,11 +180,11 @@ RSpec.describe Spree::OmniauthCallbacksController, type: :controller do
|
|
180
180
|
before { @user = create(:user, email: 'spree@gmail.com') }
|
181
181
|
|
182
182
|
it 'does not create new user' do
|
183
|
-
expect { controller.
|
183
|
+
expect { controller.github }.not_to change(Spree::User, :count)
|
184
184
|
end
|
185
185
|
|
186
186
|
it 'assigns authentication to existing user' do
|
187
|
-
expect { controller.
|
187
|
+
expect { controller.github }.to change(@user.user_authentications, :count).by(1)
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -19,10 +19,10 @@ RSpec.describe 'Admin Authentication Methods', :js do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'can create new' do
|
22
|
-
expect(page).to have_text
|
22
|
+
expect(page).to have_text 'No Authentication Methods Found, Add One!'
|
23
23
|
|
24
24
|
click_link 'New Authentication Method'
|
25
|
-
expect(page).to
|
25
|
+
expect(page).to have_link 'Back To Authentication Methods List'
|
26
26
|
select2 'Test', from: 'Environment'
|
27
27
|
select2 'Github', from: 'Social Provider'
|
28
28
|
|
@@ -53,21 +53,73 @@ RSpec.describe 'Signing in using Omniauth', :js do
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
|
-
context '
|
56
|
+
context 'github' do
|
57
57
|
before do
|
58
58
|
Spree::AuthenticationMethod.create!(
|
59
|
-
provider: '
|
59
|
+
provider: 'github',
|
60
60
|
api_key: 'fake',
|
61
61
|
api_secret: 'fake',
|
62
62
|
environment: Rails.env,
|
63
63
|
active: true
|
64
64
|
)
|
65
|
-
OmniAuth.config.
|
66
|
-
|
67
|
-
'provider' => 'twitter',
|
65
|
+
OmniAuth.config.mock_auth[:github] = {
|
66
|
+
'provider' => 'github',
|
68
67
|
'uid' => '123545',
|
69
68
|
'info' => {
|
70
69
|
'name' => 'mockuser',
|
70
|
+
'email' => 'mockuser@example.com',
|
71
|
+
'image' => 'mock_user_thumbnail_url'
|
72
|
+
},
|
73
|
+
'credentials' => {
|
74
|
+
'token' => 'mock_token',
|
75
|
+
'secret' => 'mock_secret'
|
76
|
+
}
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'going to sign in' do
|
81
|
+
visit spree.login_path
|
82
|
+
click_on 'Login with github'
|
83
|
+
expect(page).to have_text 'You are now signed in with your github account.'
|
84
|
+
click_link 'Logout'
|
85
|
+
click_link 'Login'
|
86
|
+
click_on 'Login with github'
|
87
|
+
expect(page).to have_text 'You are now signed in with your github account.'
|
88
|
+
end
|
89
|
+
|
90
|
+
# Regression test for #91
|
91
|
+
it "attempting to view 'My Account' works" do
|
92
|
+
visit spree.login_path
|
93
|
+
click_on 'Login with github'
|
94
|
+
expect(page).to have_text 'You are now signed in with your github account.'
|
95
|
+
click_link 'My Account'
|
96
|
+
expect(page).to have_text 'My Account'
|
97
|
+
end
|
98
|
+
|
99
|
+
it "view 'My Account'" do
|
100
|
+
visit spree.login_path
|
101
|
+
click_on 'Login with github'
|
102
|
+
expect(page).to have_text 'You are now signed in with your github account.'
|
103
|
+
click_link 'My Account'
|
104
|
+
expect(page).not_to have_selector 'div#social-signin-links'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'google_oauth2' do
|
109
|
+
before do
|
110
|
+
Spree::AuthenticationMethod.create!(
|
111
|
+
provider: 'google_oauth2',
|
112
|
+
api_key: 'fake',
|
113
|
+
api_secret: 'fake',
|
114
|
+
environment: Rails.env,
|
115
|
+
active: true
|
116
|
+
)
|
117
|
+
OmniAuth.config.mock_auth[:google_oauth2] = {
|
118
|
+
'provider' => 'google_oauth2',
|
119
|
+
'uid' => '123545',
|
120
|
+
'info' => {
|
121
|
+
'name' => 'mockuser',
|
122
|
+
'email' => 'mockuser@example.com',
|
71
123
|
'image' => 'mock_user_thumbnail_url'
|
72
124
|
},
|
73
125
|
'credentials' => {
|
@@ -79,11 +131,29 @@ RSpec.describe 'Signing in using Omniauth', :js do
|
|
79
131
|
|
80
132
|
it 'going to sign in' do
|
81
133
|
visit spree.login_path
|
82
|
-
click_on 'Login with
|
83
|
-
expect(page).to have_text '
|
84
|
-
|
85
|
-
|
86
|
-
|
134
|
+
click_on 'Login with google_oauth2'
|
135
|
+
expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
|
136
|
+
click_link 'Logout'
|
137
|
+
click_link 'Login'
|
138
|
+
click_on 'Login with google_oauth2'
|
139
|
+
expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
|
140
|
+
end
|
141
|
+
|
142
|
+
# Regression test for #91
|
143
|
+
it "attempting to view 'My Account' works" do
|
144
|
+
visit spree.login_path
|
145
|
+
click_on 'Login with google_oauth2'
|
146
|
+
expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
|
147
|
+
click_link 'My Account'
|
148
|
+
expect(page).to have_text 'My Account'
|
149
|
+
end
|
150
|
+
|
151
|
+
it "view 'My Account'" do
|
152
|
+
visit spree.login_path
|
153
|
+
click_on 'Login with google_oauth2'
|
154
|
+
expect(page).to have_text 'You are now signed in with your google_oauth2 account.'
|
155
|
+
click_link 'My Account'
|
156
|
+
expect(page).not_to have_selector 'div#social-signin-links'
|
87
157
|
end
|
88
158
|
end
|
89
159
|
end
|
@@ -6,6 +6,6 @@ RSpec.describe Spree::SocialConfig do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
it "holds configuration for the five default providers" do
|
9
|
-
expect(subject.providers.keys).to match_array([:
|
9
|
+
expect(subject.providers.keys).to match_array([:facebook, :github, :google_oauth2])
|
10
10
|
end
|
11
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_social
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Dyer
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deface
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: omniauth-amazon
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: omniauth-facebook
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +95,7 @@ dependencies:
|
|
109
95
|
- !ruby/object:Gem::Version
|
110
96
|
version: '0'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: omniauth-
|
98
|
+
name: omniauth-rails_csrf_protection
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - ">="
|
@@ -145,7 +131,7 @@ dependencies:
|
|
145
131
|
version: 2.0.0
|
146
132
|
- - "<"
|
147
133
|
- !ruby/object:Gem::Version
|
148
|
-
version: '
|
134
|
+
version: '4'
|
149
135
|
type: :runtime
|
150
136
|
prerelease: false
|
151
137
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -155,21 +141,21 @@ dependencies:
|
|
155
141
|
version: 2.0.0
|
156
142
|
- - "<"
|
157
143
|
- !ruby/object:Gem::Version
|
158
|
-
version: '
|
144
|
+
version: '4'
|
159
145
|
- !ruby/object:Gem::Dependency
|
160
146
|
name: solidus_support
|
161
147
|
requirement: !ruby/object:Gem::Requirement
|
162
148
|
requirements:
|
163
149
|
- - "~>"
|
164
150
|
- !ruby/object:Gem::Version
|
165
|
-
version: 0.
|
151
|
+
version: '0.5'
|
166
152
|
type: :runtime
|
167
153
|
prerelease: false
|
168
154
|
version_requirements: !ruby/object:Gem::Requirement
|
169
155
|
requirements:
|
170
156
|
- - "~>"
|
171
157
|
- !ruby/object:Gem::Version
|
172
|
-
version: 0.
|
158
|
+
version: '0.5'
|
173
159
|
- !ruby/object:Gem::Dependency
|
174
160
|
name: solidus_dev_support
|
175
161
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,7 +170,7 @@ dependencies:
|
|
184
170
|
- - ">="
|
185
171
|
- !ruby/object:Gem::Version
|
186
172
|
version: '0'
|
187
|
-
description:
|
173
|
+
description:
|
188
174
|
email: jdyer@spreecommerce.com
|
189
175
|
executables: []
|
190
176
|
extensions: []
|
@@ -192,7 +178,7 @@ extra_rdoc_files: []
|
|
192
178
|
files:
|
193
179
|
- ".circleci/config.yml"
|
194
180
|
- ".gem_release.yml"
|
195
|
-
- ".github/
|
181
|
+
- ".github/dependabot.yml"
|
196
182
|
- ".gitignore"
|
197
183
|
- ".rspec"
|
198
184
|
- ".rubocop.yml"
|
@@ -208,11 +194,12 @@ files:
|
|
208
194
|
- app/controllers/spree/admin/authentication_methods_controller.rb
|
209
195
|
- app/controllers/spree/omniauth_callbacks_controller.rb
|
210
196
|
- app/controllers/spree/user_authentications_controller.rb
|
197
|
+
- app/core/spree/permission_sets/authentication_method_display.rb
|
198
|
+
- app/core/spree/permission_sets/authentication_method_management.rb
|
211
199
|
- app/decorators/controllers/solidus_social/spree/user_registrations_controller_decorator.rb
|
212
200
|
- app/decorators/models/solidus_social/spree/user_decorator.rb
|
213
201
|
- app/helpers/spree/omniauth_callbacks_helper.rb
|
214
202
|
- app/models/spree/authentication_method.rb
|
215
|
-
- app/models/spree/social_configuration.rb
|
216
203
|
- app/models/spree/user_authentication.rb
|
217
204
|
- app/overrides/add_authentications_to_account_summary.rb
|
218
205
|
- app/overrides/admin_configuration_decorator.rb
|
@@ -233,6 +220,7 @@ files:
|
|
233
220
|
- config/locales/de.yml
|
234
221
|
- config/locales/en.yml
|
235
222
|
- config/locales/es-MX.yml
|
223
|
+
- config/locales/es.yml
|
236
224
|
- config/locales/fr.yml
|
237
225
|
- config/locales/it.yml
|
238
226
|
- config/locales/nl.yml
|
@@ -247,6 +235,7 @@ files:
|
|
247
235
|
- lib/solidus_social/engine.rb
|
248
236
|
- lib/solidus_social/facebook_omniauth_strategy_ext.rb
|
249
237
|
- lib/solidus_social/factories.rb
|
238
|
+
- lib/solidus_social/social_configuration.rb
|
250
239
|
- lib/solidus_social/version.rb
|
251
240
|
- solidus_social.gemspec
|
252
241
|
- spec/controllers/spree/omniauth_callbacks_controller_spec.rb
|
@@ -267,13 +256,13 @@ metadata:
|
|
267
256
|
homepage_uri: https://github.com/solidusio-contrib/solidus_social#readme
|
268
257
|
source_code_uri: https://github.com/solidusio-contrib/solidus_social
|
269
258
|
changelog_uri: https://github.com/solidusio-contrib/solidus_social/blob/master/CHANGELOG.md
|
270
|
-
post_install_message:
|
259
|
+
post_install_message:
|
271
260
|
rdoc_options: []
|
272
261
|
require_paths:
|
273
262
|
- lib
|
274
263
|
required_ruby_version: !ruby/object:Gem::Requirement
|
275
264
|
requirements:
|
276
|
-
- - "
|
265
|
+
- - ">="
|
277
266
|
- !ruby/object:Gem::Version
|
278
267
|
version: '2.4'
|
279
268
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -282,8 +271,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
282
271
|
- !ruby/object:Gem::Version
|
283
272
|
version: '0'
|
284
273
|
requirements: []
|
285
|
-
rubygems_version: 3.
|
286
|
-
signing_key:
|
274
|
+
rubygems_version: 3.3.17
|
275
|
+
signing_key:
|
287
276
|
specification_version: 4
|
288
277
|
summary: Adds social network login services (OAuth) to Solidus
|
289
278
|
test_files:
|
data/.github/stale.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# Number of days of inactivity before an issue becomes stale
|
2
|
-
daysUntilStale: 60
|
3
|
-
# Number of days of inactivity before a stale issue is closed
|
4
|
-
daysUntilClose: 7
|
5
|
-
# Issues with these labels will never be considered stale
|
6
|
-
exemptLabels:
|
7
|
-
- pinned
|
8
|
-
- security
|
9
|
-
# Label to use when marking an issue as stale
|
10
|
-
staleLabel: wontfix
|
11
|
-
# Comment to post when marking an issue as stale. Set to `false` to disable
|
12
|
-
markComment: >
|
13
|
-
This issue has been automatically marked as stale because it has not had
|
14
|
-
recent activity. It will be closed if no further activity occurs. Thank you
|
15
|
-
for your contributions.
|
16
|
-
# Comment to post when closing a stale issue. Set to `false` to disable
|
17
|
-
closeComment: false
|