stormpath-rails 2.6.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/app/controllers/stormpath/rails/base_controller.rb +10 -2
- data/app/controllers/stormpath/rails/forgot_password/create_controller.rb +2 -1
- data/app/controllers/stormpath/rails/id_site_callback/new_controller.rb +45 -12
- data/app/controllers/stormpath/rails/login/create_controller.rb +2 -1
- data/app/controllers/stormpath/rails/logout/create_controller.rb +3 -2
- data/app/controllers/stormpath/rails/register/create_controller.rb +2 -0
- data/app/forms/stormpath/rails/organization_form.rb +3 -1
- data/app/forms/stormpath/rails/registration_form.rb +4 -1
- data/app/helpers/social_helper.rb +38 -0
- data/app/services/stormpath/rails/delete_access_token.rb +4 -2
- data/app/services/stormpath/rails/social_directories.rb +29 -0
- data/app/services/stormpath/rails/social_login_url_builder.rb +64 -0
- data/app/services/stormpath/rails/token_cookie_setter.rb +3 -1
- data/app/services/stormpath/rails/url_builder.rb +2 -4
- data/app/views/stormpath/rails/shared/_social_login.html.erb +10 -16
- data/bin/rails +2 -1
- data/docs/changelog.rst +8 -0
- data/lib/stormpath/rails.rb +2 -0
- data/lib/stormpath/rails/base_url_initializer.rb +32 -0
- data/lib/stormpath/rails/client.rb +3 -1
- data/lib/stormpath/rails/config/account_store_verification.rb +4 -2
- data/lib/stormpath/rails/config/application_client_api.rb +16 -0
- data/lib/stormpath/rails/config/application_resolution.rb +4 -8
- data/lib/stormpath/rails/config/dynamic_configuration.rb +5 -0
- data/lib/stormpath/rails/config/multitenancy_verification.rb +2 -1
- data/lib/stormpath/rails/config/social_login_verification.rb +8 -10
- data/lib/stormpath/rails/configuration.rb +2 -0
- data/lib/stormpath/rails/content_type_negotiator.rb +1 -2
- data/lib/stormpath/rails/version.rb +1 -2
- data/stormpath-rails.gemspec +1 -1
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 212204b2cb03d9b5dfaa4f7b63fc3ab0d9b033e2
|
4
|
+
data.tar.gz: fd25eb7f34d2bb5a70d513080683a65ca646ed7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22d981c58901860bf5dc410f243a0c25a02079de19e569ac07f68fb9fd5634c9980a0f7ff7343b4b443b1f0448a7f1f45aa7a3332b1a4de15381a0daec1869fc
|
7
|
+
data.tar.gz: bcd83712b69cd7d1eee54294fc1d63cfc5a3166e5e04537b01a9d840c2b98c34862faf812b1b150ab829ece331e5bc0609f1af4f2d5b7fc75bb11039f89e85d3
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
Stormpath Rails Changelog
|
2
2
|
============================
|
3
3
|
|
4
|
+
Version 2.7.0
|
5
|
+
-------------
|
6
|
+
Released on Feb 06, 2017
|
7
|
+
- Social login now uses the Client API for authentication (Social login v2)
|
8
|
+
- Automatically initialize base href from application href (after this version you don't have to set the basePath explicitly in the stormpath.yml)
|
9
|
+
- Code refactoring
|
10
|
+
|
11
|
+
|
4
12
|
Version 2.6.0
|
5
13
|
-------------
|
6
14
|
Released on Jan 24, 2017
|
data/README.md
CHANGED
@@ -41,8 +41,9 @@ module Stormpath
|
|
41
41
|
|
42
42
|
def current_organization
|
43
43
|
if stormpath_config.web.multi_tenancy.enabled
|
44
|
-
Stormpath::Rails::OrganizationResolver.new(
|
45
|
-
|
44
|
+
Stormpath::Rails::OrganizationResolver.new(
|
45
|
+
req, params[:organization_name_key]
|
46
|
+
).organization
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
@@ -55,6 +56,13 @@ module Stormpath
|
|
55
56
|
end
|
56
57
|
helper_method :current_organization_name_key
|
57
58
|
|
59
|
+
def social_auth
|
60
|
+
@social_auth ||= SocialLoginUrlBuilder.call(
|
61
|
+
req.base_url, organization_name_key: current_organization_name_key
|
62
|
+
)
|
63
|
+
end
|
64
|
+
helper_method :social_auth
|
65
|
+
|
58
66
|
def req
|
59
67
|
request
|
60
68
|
end
|
@@ -12,7 +12,8 @@ module Stormpath
|
|
12
12
|
respond_with_success
|
13
13
|
rescue SendPasswordResetEmail::UnexistingEmailError
|
14
14
|
respond_with_success
|
15
|
-
rescue SendPasswordResetEmail::NoEmailError,
|
15
|
+
rescue SendPasswordResetEmail::NoEmailError,
|
16
|
+
Stormpath::Rails::OrganizationForm::FormError => error
|
16
17
|
respond_with_error(error)
|
17
18
|
end
|
18
19
|
end
|
@@ -7,8 +7,10 @@ module Stormpath
|
|
7
7
|
begin
|
8
8
|
if id_site_result.status == 'LOGOUT'
|
9
9
|
TokenAndCookiesCleaner.new(cookies).remove
|
10
|
-
|
11
|
-
|
10
|
+
elsif id_site_result.status == 'AUTHENTICATED'
|
11
|
+
login_account_and_set_cookies
|
12
|
+
elsif id_site_result.status == 'REGISTERED'
|
13
|
+
login_account_and_set_cookies if valid_for_login?
|
12
14
|
end
|
13
15
|
|
14
16
|
respond_with_success
|
@@ -19,7 +21,7 @@ module Stormpath
|
|
19
21
|
|
20
22
|
private
|
21
23
|
|
22
|
-
def
|
24
|
+
def login_account_and_set_cookies
|
23
25
|
AccountLoginWithStormpathToken.new(
|
24
26
|
cookies, account,
|
25
27
|
Stormpath::Rails::Client.application,
|
@@ -30,13 +32,21 @@ module Stormpath
|
|
30
32
|
def respond_with_success
|
31
33
|
if id_site_result.status == 'LOGOUT'
|
32
34
|
respond_to do |format|
|
33
|
-
format.html
|
34
|
-
|
35
|
+
format.html do
|
36
|
+
redirect_to(stormpath_config.web.logout.next_uri,
|
37
|
+
notice: 'You have been logged out successfully.')
|
38
|
+
end
|
39
|
+
format.json { render nothing: true, status: 200 }
|
35
40
|
end
|
36
|
-
|
41
|
+
elsif id_site_result.status == 'AUTHENTICATED'
|
37
42
|
respond_to do |format|
|
38
43
|
format.html { redirect_to login_redirect_route, notice: 'Successfully signed in' }
|
39
|
-
format.json { render json:
|
44
|
+
format.json { render json: serialized_account }
|
45
|
+
end
|
46
|
+
elsif id_site_result.status == 'REGISTERED'
|
47
|
+
respond_to do |format|
|
48
|
+
format.html { redirect_to register_redirect_route }
|
49
|
+
format.json { render json: serialized_account }
|
40
50
|
end
|
41
51
|
end
|
42
52
|
end
|
@@ -53,16 +63,39 @@ module Stormpath
|
|
53
63
|
end
|
54
64
|
end
|
55
65
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
66
|
+
def valid_for_login?
|
67
|
+
auto_login_enabled? && !email_verification_enabled?
|
68
|
+
end
|
69
|
+
|
70
|
+
def register_redirect_route
|
71
|
+
if email_verification_enabled?
|
72
|
+
"#{stormpath_config.web.login.uri}?status=unverified"
|
73
|
+
elsif auto_login_enabled?
|
74
|
+
stormpath_config.web.register.next_uri
|
59
75
|
else
|
60
|
-
stormpath_config.web.login.
|
76
|
+
"#{stormpath_config.web.login.uri}?status=created"
|
61
77
|
end
|
62
78
|
end
|
63
79
|
|
80
|
+
def email_verification_enabled?
|
81
|
+
account.status == 'UNVERIFIED'
|
82
|
+
end
|
83
|
+
|
84
|
+
def auto_login_enabled?
|
85
|
+
stormpath_config.web.register.auto_login
|
86
|
+
end
|
87
|
+
|
88
|
+
def serialized_account
|
89
|
+
AccountSerializer.to_h(account)
|
90
|
+
end
|
91
|
+
|
92
|
+
def login_redirect_route
|
93
|
+
params[:next] ? URI(params[:next]).path : stormpath_config.web.login.next_uri
|
94
|
+
end
|
95
|
+
|
64
96
|
def id_site_result
|
65
|
-
@id_site_result ||=
|
97
|
+
@id_site_result ||=
|
98
|
+
Stormpath::Rails::Client.application.handle_id_site_callback(request.url)
|
66
99
|
end
|
67
100
|
|
68
101
|
def account
|
@@ -9,7 +9,8 @@ module Stormpath
|
|
9
9
|
form.save!
|
10
10
|
set_cookies if account_login?
|
11
11
|
respond_with_success
|
12
|
-
rescue Stormpath::Error, LoginForm::FormError, SocialLoginForm::FormError,
|
12
|
+
rescue Stormpath::Error, LoginForm::FormError, SocialLoginForm::FormError,
|
13
|
+
OrganizationForm::FormError, OrganizationResolver::Error => error
|
13
14
|
respond_with_error(error)
|
14
15
|
end
|
15
16
|
end
|
@@ -40,8 +40,9 @@ module Stormpath
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def stormpath_id_site_logout_url
|
43
|
-
Stormpath::Rails::Client.application.create_id_site_url(
|
44
|
-
|
43
|
+
Stormpath::Rails::Client.application.create_id_site_url(
|
44
|
+
callback_uri: id_site_result_url, logout: true
|
45
|
+
)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
@@ -16,7 +16,9 @@ module Stormpath
|
|
16
16
|
|
17
17
|
def save!
|
18
18
|
begin
|
19
|
-
Stormpath::Rails::OrganizationResolver.new(
|
19
|
+
Stormpath::Rails::OrganizationResolver.new(
|
20
|
+
OpenStruct.new(subdomains: [name_key])
|
21
|
+
).organization
|
20
22
|
rescue Stormpath::Rails::OrganizationResolver::Error
|
21
23
|
raise FormError, 'Organization could not be found'
|
22
24
|
end
|
@@ -74,7 +74,10 @@ module Stormpath
|
|
74
74
|
|
75
75
|
def organization
|
76
76
|
begin
|
77
|
-
@organization ||=
|
77
|
+
@organization ||=
|
78
|
+
Stormpath::Rails::Client.client.organizations.search(
|
79
|
+
name_key: organization_name_key
|
80
|
+
).first
|
78
81
|
rescue Stormpath::Error
|
79
82
|
nil
|
80
83
|
end
|
@@ -11,6 +11,44 @@ module SocialHelper
|
|
11
11
|
social_providers_present? ? 'col-sm-12' : 'col-sm-8'
|
12
12
|
end
|
13
13
|
|
14
|
+
def social_login_v2_enabled?
|
15
|
+
Stormpath::Rails.config.web.callback.enabled &&
|
16
|
+
Stormpath::Rails.config.web.client_api.enabled &&
|
17
|
+
Stormpath::Rails.config.web.client_api.domain_name.present?
|
18
|
+
end
|
19
|
+
|
20
|
+
def facebook_enabled?
|
21
|
+
Stormpath::Rails.config.web.facebook_app_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def github_enabled?
|
25
|
+
Stormpath::Rails.config.web.github_app_id
|
26
|
+
end
|
27
|
+
|
28
|
+
def google_enabled?
|
29
|
+
Stormpath::Rails.config.web.google_app_id
|
30
|
+
end
|
31
|
+
|
32
|
+
def linkedin_enabled?
|
33
|
+
Stormpath::Rails.config.web.linkedin_app_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def link_to_facebook_login(url)
|
37
|
+
link_to 'Facebook', url, class: 'btn btn-social btn-facebook' if facebook_enabled? && url.present?
|
38
|
+
end
|
39
|
+
|
40
|
+
def link_to_google_login(url)
|
41
|
+
link_to 'Google', url, class: 'btn btn-social btn-google' if google_enabled? && url.present?
|
42
|
+
end
|
43
|
+
|
44
|
+
def link_to_linkedin_login(url)
|
45
|
+
link_to 'LinkedIn', url, class: 'btn btn-social btn-linkedin' if linkedin_enabled? && url.present?
|
46
|
+
end
|
47
|
+
|
48
|
+
def link_to_github_login(url)
|
49
|
+
link_to 'GitHub', url, class: 'btn btn-social btn-github' if github_enabled? && url.present?
|
50
|
+
end
|
51
|
+
|
14
52
|
def facebook_oauth_url
|
15
53
|
URI::HTTPS.build(
|
16
54
|
host: 'www.facebook.com',
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Stormpath
|
2
|
+
module Rails
|
3
|
+
class SocialDirectories
|
4
|
+
def self.for(application)
|
5
|
+
new(application).call
|
6
|
+
end
|
7
|
+
|
8
|
+
def initialize(application)
|
9
|
+
@application = application
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
application.account_store_mappings.select do |mapping|
|
14
|
+
account_store = mapping.account_store
|
15
|
+
account_store if social_directory?(account_store)
|
16
|
+
end.map(&:account_store)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def social_directory?(account_store)
|
22
|
+
account_store.class == Stormpath::Resource::Directory &&
|
23
|
+
account_store.provider.respond_to?(:client_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :application
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Stormpath
|
2
|
+
module Rails
|
3
|
+
class SocialLoginUrlBuilder
|
4
|
+
attr_reader :base_url, :organization_name_key
|
5
|
+
|
6
|
+
def self.call(base_url, options = {})
|
7
|
+
new(base_url, options[:organization_name_key])
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(base_url, organization_name_key = nil)
|
11
|
+
@base_url = base_url
|
12
|
+
@organization_name_key = organization_name_key
|
13
|
+
initialize_directories
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def initialize_directories
|
19
|
+
social_directories.each do |account_store|
|
20
|
+
instance_variable_set("@#{account_store.provider.provider_id}_login_url",
|
21
|
+
login_url_for(account_store))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def login_url_for(directory)
|
26
|
+
URI.unescape(URI::HTTPS.build(
|
27
|
+
host: Stormpath::Rails.config.web.client_api.domain_name,
|
28
|
+
path: '/authorize',
|
29
|
+
query: query_parameters_for(directory).to_query
|
30
|
+
).to_s)
|
31
|
+
end
|
32
|
+
|
33
|
+
def query_parameters_for(directory)
|
34
|
+
{}.tap do |body|
|
35
|
+
body[:response_type] = 'stormpath_token'
|
36
|
+
body[:account_store_href] = directory.href
|
37
|
+
body[:scope] = directory.provider.scope.join('+')
|
38
|
+
body[:redirect_uri] = "#{base_url}#{Stormpath::Rails.config.web.callback.uri}"
|
39
|
+
body[:organization_name_key] = organization_name_key if organization_name_key.present?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def application
|
44
|
+
@application ||= Stormpath::Rails::Client.application
|
45
|
+
end
|
46
|
+
|
47
|
+
def social_directories
|
48
|
+
@social_directories ||= SocialDirectories.for(application)
|
49
|
+
end
|
50
|
+
|
51
|
+
def method_missing(method_name, *args, &block)
|
52
|
+
if instance_variable_names.include? "@#{method_name}"
|
53
|
+
instance_variable_get "@#{method_name}"
|
54
|
+
else
|
55
|
+
''
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def respond_to_missing?(method_name, include_private = false)
|
60
|
+
method_name.to_s.end_with?('_login_url') || super
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -58,7 +58,9 @@ class SingleTokenCookieSetter
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def expires
|
61
|
-
Time.zone.at(
|
61
|
+
Time.zone.at(
|
62
|
+
JWT.decode(token, Stormpath::Rails::Client.client.data_store.api_key.secret).first['exp']
|
63
|
+
)
|
62
64
|
end
|
63
65
|
|
64
66
|
def http_only
|
@@ -4,21 +4,15 @@
|
|
4
4
|
</div>
|
5
5
|
|
6
6
|
<label>Easy 1-click login:</label>
|
7
|
-
|
8
|
-
|
9
|
-
<%=
|
10
|
-
|
11
|
-
|
12
|
-
<%
|
13
|
-
<%=
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
<%= link_to 'LinkedIn', linkedin_oauth_url, class: 'btn btn-social btn-linkedin' %>
|
18
|
-
<% end %>
|
19
|
-
|
20
|
-
<% if Stormpath::Rails.config.web.github_app_id %>
|
21
|
-
<%= link_to 'GitHub', github_oauth_url, class: 'btn btn-social btn-github' %>
|
7
|
+
<% if social_login_v2_enabled? %>
|
8
|
+
<%= link_to_facebook_login(social_auth.facebook_login_url) %>
|
9
|
+
<%= link_to_google_login(social_auth.google_login_url) %>
|
10
|
+
<%= link_to_linkedin_login(social_auth.linkedin_login_url) %>
|
11
|
+
<%= link_to_github_login(social_auth.github_login_url) %>
|
12
|
+
<% else %>
|
13
|
+
<%= link_to_facebook_login(facebook_oauth_url) %>
|
14
|
+
<%= link_to_google_login(google_oauth_url) %>
|
15
|
+
<%= link_to_linkedin_login(linkedin_oauth_url) %>
|
16
|
+
<%= link_to_github_login(github_oauth_url) %>
|
22
17
|
<% end %>
|
23
|
-
|
24
18
|
</div>
|
data/bin/rails
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the
|
3
|
+
# root of your application.
|
3
4
|
|
4
5
|
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
6
|
ENGINE_PATH = File.expand_path('../../lib/stormpath/rails/engine', __FILE__)
|
data/docs/changelog.rst
CHANGED
@@ -6,6 +6,14 @@ Change Log
|
|
6
6
|
|
7
7
|
Gem changes until version 2.0.1, in descending order.
|
8
8
|
|
9
|
+
Version 2.7.0
|
10
|
+
-------------
|
11
|
+
Released on Feb 06, 2017
|
12
|
+
- Social login now uses the Client API for authentication (Social login v2)
|
13
|
+
- Automatically initialize base href from application href (after this version you don't have to set the basePath explicitly in the stormpath.yml)
|
14
|
+
- Code refactoring
|
15
|
+
|
16
|
+
|
9
17
|
Version 2.6.0
|
10
18
|
-------------
|
11
19
|
Released on Jan 24, 2017
|
data/lib/stormpath/rails.rb
CHANGED
@@ -3,6 +3,7 @@ require 'stormpath/rails/engine'
|
|
3
3
|
require 'stormpath/rails/config/read_file'
|
4
4
|
require 'stormpath/rails/config/application_resolution'
|
5
5
|
require 'stormpath/rails/config/account_store_verification'
|
6
|
+
require 'stormpath/rails/config/application_client_api'
|
6
7
|
require 'stormpath/rails/config/dynamic_configuration'
|
7
8
|
require 'stormpath/rails/config/multitenancy_verification'
|
8
9
|
require 'stormpath/rails/config/id_site_verification'
|
@@ -18,6 +19,7 @@ module Stormpath
|
|
18
19
|
autoload :Version, 'stormpath/rails/version'
|
19
20
|
autoload :Social, 'stormpath/rails/social'
|
20
21
|
autoload :ApiKey, 'stormpath/rails/api_key'
|
22
|
+
autoload :BaseUrlInitializer, 'stormpath/rails/base_url_initializer'
|
21
23
|
autoload :ContentTypeNegotiator, 'stormpath/rails/content_type_negotiator'
|
22
24
|
autoload :RoutingConstraint, 'stormpath/rails/routing_constraint'
|
23
25
|
autoload :InvalidSptokenError, 'stormpath/rails/errors/invalid_sptoken_error'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Stormpath
|
2
|
+
module Rails
|
3
|
+
class BaseUrlInitializer
|
4
|
+
DEFAULT_API_VERSION = 1
|
5
|
+
DEFAULT_API_SCHEME = 'https'.freeze
|
6
|
+
attr_reader :application_uri, :base_url
|
7
|
+
|
8
|
+
def initialize(application_href)
|
9
|
+
@application_uri = URI(application_href)
|
10
|
+
@base_url = extract_base_url_from_uri
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.call(application_href)
|
14
|
+
if application_href.blank?
|
15
|
+
raise(InvalidConfiguration,
|
16
|
+
'Please set the application href in your configuration options.')
|
17
|
+
end
|
18
|
+
new(application_href).base_url
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def extract_base_url_from_uri
|
24
|
+
"#{DEFAULT_API_SCHEME}://#{host}/v#{DEFAULT_API_VERSION}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def host
|
28
|
+
application_uri.host
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -32,7 +32,9 @@ module Stormpath
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.base_url
|
35
|
-
Stormpath::Rails.
|
35
|
+
Stormpath::Rails::BaseUrlInitializer.call(
|
36
|
+
Stormpath::Rails.config.merged_config_hashes['stormpath']['application']['href']
|
37
|
+
)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -20,7 +20,8 @@ module Stormpath
|
|
20
20
|
return if app_has_account_store_mappings?
|
21
21
|
raise(
|
22
22
|
InvalidConfiguration,
|
23
|
-
'No account stores are mapped to the specified application. Account stores are
|
23
|
+
'No account stores are mapped to the specified application. Account stores are '\
|
24
|
+
'required for login and registration.'
|
24
25
|
)
|
25
26
|
end
|
26
27
|
|
@@ -28,7 +29,8 @@ module Stormpath
|
|
28
29
|
return if app_has_default_account_store_mapping?
|
29
30
|
raise(
|
30
31
|
InvalidConfiguration,
|
31
|
-
'No default account store is mapped to the specified application. A default account
|
32
|
+
'No default account store is mapped to the specified application. A default account '\
|
33
|
+
'store is required for registration.'
|
32
34
|
)
|
33
35
|
end
|
34
36
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Stormpath
|
2
|
+
module Rails
|
3
|
+
module Config
|
4
|
+
class ApplicationClientApi
|
5
|
+
attr_reader :app, :web_config, :client_api_enabled, :client_api_domain
|
6
|
+
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
@web_config = app.web_config
|
10
|
+
@client_api_enabled = web_config.status == 'ENABLED'
|
11
|
+
@client_api_domain = web_config.domain_name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -56,19 +56,15 @@ module Stormpath
|
|
56
56
|
|
57
57
|
def verify_application_href
|
58
58
|
if href && href !~ /applications/
|
59
|
-
raise(
|
60
|
-
InvalidConfiguration,
|
61
|
-
"#{href} is not a valid Stormpath Application href."
|
62
|
-
)
|
59
|
+
raise(InvalidConfiguration, "#{href} is not a valid Stormpath Application href.")
|
63
60
|
end
|
64
61
|
end
|
65
62
|
|
66
63
|
def app_from_name
|
67
64
|
application = Stormpath::Rails::Client.client.applications.search(name: name).first
|
68
|
-
application || raise(
|
69
|
-
|
70
|
-
|
71
|
-
)
|
65
|
+
application || raise(InvalidConfiguration,
|
66
|
+
'The provided application could not be found. The provided'\
|
67
|
+
" application name was: #{name}")
|
72
68
|
end
|
73
69
|
end
|
74
70
|
end
|
@@ -13,6 +13,7 @@ module Stormpath
|
|
13
13
|
:linkedin_app_id,
|
14
14
|
to: :social_login_verification
|
15
15
|
)
|
16
|
+
delegate(:client_api_enabled, :client_api_domain, to: :application_client_api)
|
16
17
|
|
17
18
|
def initialize(static_config)
|
18
19
|
@static_config = static_config
|
@@ -71,6 +72,10 @@ module Stormpath
|
|
71
72
|
).call
|
72
73
|
end
|
73
74
|
|
75
|
+
def application_client_api
|
76
|
+
ApplicationClientApi.new(app)
|
77
|
+
end
|
78
|
+
|
74
79
|
def process_multitenancy_verification
|
75
80
|
MultitenancyVerification.new(static_config.stormpath.web).call
|
76
81
|
end
|
@@ -18,7 +18,8 @@ module Stormpath
|
|
18
18
|
return if multitenancy_set_correctly?
|
19
19
|
raise(
|
20
20
|
InvalidConfiguration,
|
21
|
-
|
21
|
+
'Multitenancy is not set correctly in the configuration file. '\
|
22
|
+
"It needs to have a domainName and multitenancy strategy set to 'subdomain'"
|
22
23
|
)
|
23
24
|
end
|
24
25
|
|
@@ -2,13 +2,9 @@ module Stormpath
|
|
2
2
|
module Rails
|
3
3
|
module Config
|
4
4
|
class SocialLoginVerification
|
5
|
-
attr_reader :app,
|
6
|
-
:
|
7
|
-
:
|
8
|
-
:github_app_id,
|
9
|
-
:github_app_secret,
|
10
|
-
:google_app_id,
|
11
|
-
:linkedin_app_id
|
5
|
+
attr_reader :app, :facebook_app_id, :facebook_app_secret,
|
6
|
+
:github_app_id, :github_app_secret,
|
7
|
+
:google_app_id, :linkedin_app_id
|
12
8
|
|
13
9
|
def initialize(app_href)
|
14
10
|
@app = Stormpath::Rails::Client.client.applications.get(app_href)
|
@@ -18,9 +14,7 @@ module Stormpath
|
|
18
14
|
private
|
19
15
|
|
20
16
|
def initialize_directories
|
21
|
-
|
22
|
-
account_store = mapping.account_store
|
23
|
-
next unless account_store.class == Stormpath::Resource::Directory
|
17
|
+
social_directories.each do |account_store|
|
24
18
|
case account_store.provider.provider_id
|
25
19
|
when 'facebook'
|
26
20
|
@facebook_app_id = account_store.provider.client_id
|
@@ -35,6 +29,10 @@ module Stormpath
|
|
35
29
|
end
|
36
30
|
end
|
37
31
|
end
|
32
|
+
|
33
|
+
def social_directories
|
34
|
+
@social_directories ||= SocialDirectories.for(app)
|
35
|
+
end
|
38
36
|
end
|
39
37
|
end
|
40
38
|
end
|
@@ -34,6 +34,8 @@ module Stormpath
|
|
34
34
|
config.stormpath.web.linkedin_app_id = dynamic_config.linkedin_app_id
|
35
35
|
config.stormpath.web.has_social_providers = dynamic_config.has_social_providers?
|
36
36
|
config.stormpath.web.verify_email.enabled = dynamic_config.verify_email_enabled?
|
37
|
+
config.stormpath.web.client_api = { enabled: dynamic_config.client_api_enabled,
|
38
|
+
domain_name: dynamic_config.client_api_domain }
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
1
|
module Stormpath
|
3
2
|
module Rails
|
4
3
|
class ContentTypeNegotiator
|
@@ -43,7 +42,7 @@ module Stormpath
|
|
43
42
|
HTTP_ACCEPT_JSON
|
44
43
|
elsif accept_header.include?(HTTP_ACCEPT_HTML)
|
45
44
|
HTTP_ACCEPT_HTML
|
46
|
-
|
45
|
+
end
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
data/stormpath-rails.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
-
spec.add_dependency 'stormpath-sdk', '>= 1.
|
25
|
+
spec.add_dependency 'stormpath-sdk', '>= 1.6.0'
|
26
26
|
spec.add_dependency 'virtus'
|
27
27
|
spec.add_dependency 'rails', '>= 3.1'
|
28
28
|
spec.add_dependency 'recursive-open-struct'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stormpath-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nenad Nikolic
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: stormpath-sdk
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.6.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.6.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: virtus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +157,8 @@ files:
|
|
157
157
|
- app/services/stormpath/rails/refresh_token_authentication.rb
|
158
158
|
- app/services/stormpath/rails/resend_email_verification.rb
|
159
159
|
- app/services/stormpath/rails/send_password_reset_email.rb
|
160
|
+
- app/services/stormpath/rails/social_directories.rb
|
161
|
+
- app/services/stormpath/rails/social_login_url_builder.rb
|
160
162
|
- app/services/stormpath/rails/token_and_cookies_cleaner.rb
|
161
163
|
- app/services/stormpath/rails/token_cookie_setter.rb
|
162
164
|
- app/services/stormpath/rails/url_builder.rb
|
@@ -242,8 +244,10 @@ files:
|
|
242
244
|
- lib/stormpath-rails.rb
|
243
245
|
- lib/stormpath/rails.rb
|
244
246
|
- lib/stormpath/rails/api_key.rb
|
247
|
+
- lib/stormpath/rails/base_url_initializer.rb
|
245
248
|
- lib/stormpath/rails/client.rb
|
246
249
|
- lib/stormpath/rails/config/account_store_verification.rb
|
250
|
+
- lib/stormpath/rails/config/application_client_api.rb
|
247
251
|
- lib/stormpath/rails/config/application_resolution.rb
|
248
252
|
- lib/stormpath/rails/config/dynamic_configuration.rb
|
249
253
|
- lib/stormpath/rails/config/id_site_verification.rb
|