stormpath-rails 1.1.2.beta → 2.0.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/.gitignore +1 -0
- data/.rspec +1 -1
- data/.rubocop.yml +22 -0
- data/.travis.yml +6 -3
- data/Gemfile +10 -3
- data/README.md +139 -142
- data/Rakefile +9 -9
- data/app/assets/stylesheets/stormpath.css.scss +3 -2
- data/app/controllers/stormpath/rails/base_controller.rb +25 -6
- data/app/controllers/stormpath/rails/change_password/create_controller.rb +68 -0
- data/app/controllers/stormpath/rails/change_password/new_controller.rb +38 -0
- data/app/controllers/stormpath/rails/forgot_password/create_controller.rb +37 -0
- data/app/controllers/stormpath/rails/forgot_password/new_controller.rb +14 -0
- data/app/controllers/stormpath/rails/login/create_controller.rb +60 -0
- data/app/controllers/stormpath/rails/login/new_controller.rb +20 -0
- data/app/controllers/stormpath/rails/logout/create_controller.rb +61 -0
- data/app/controllers/stormpath/rails/oauth2/create_controller.rb +82 -0
- data/app/controllers/stormpath/rails/oauth2/new_controller.rb +11 -0
- data/app/controllers/stormpath/rails/profile/show_controller.rb +15 -0
- data/app/controllers/stormpath/rails/register/create_controller.rb +86 -0
- data/app/controllers/stormpath/rails/register/new_controller.rb +20 -0
- data/app/controllers/stormpath/rails/verify_email/create_controller.rb +37 -0
- data/app/controllers/stormpath/rails/verify_email/show_controller.rb +51 -0
- data/app/forms/stormpath/rails/login_form.rb +60 -0
- data/app/forms/stormpath/rails/registration_form.rb +106 -0
- data/app/forms/stormpath/rails/registration_form_fields.rb +71 -0
- data/app/helpers/social_helper.rb +2 -1
- data/app/serializers/stormpath/rails/account_serializer.rb +32 -0
- data/app/serializers/stormpath/rails/form_serializer.rb +37 -0
- data/app/serializers/stormpath/rails/login_new_serializer.rb +11 -0
- data/app/serializers/stormpath/rails/profile_serializer.rb +71 -0
- data/app/serializers/stormpath/rails/registration_form_serializer.rb +11 -0
- data/app/services/stormpath/rails/account_from_access_token/local_account_resolution.rb +48 -0
- data/app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb +27 -0
- data/app/services/stormpath/rails/account_from_access_token.rb +33 -0
- data/app/services/stormpath/rails/account_login.rb +28 -0
- data/app/services/stormpath/rails/account_login_with_stormpath_token.rb +32 -0
- data/app/services/stormpath/rails/client_credentials_authentication.rb +40 -0
- data/app/services/stormpath/rails/controller_authentication/from_basic_auth.rb +45 -0
- data/app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb +34 -0
- data/app/services/stormpath/rails/controller_authentication/from_cookies.rb +71 -0
- data/app/services/stormpath/rails/controller_authentication.rb +44 -0
- data/app/services/stormpath/rails/delete_access_token.rb +48 -0
- data/app/services/stormpath/rails/delete_refresh_token.rb +11 -0
- data/app/services/stormpath/rails/forgot_password_token_verification.rb +31 -0
- data/app/services/stormpath/rails/password_change.rb +17 -0
- data/app/services/stormpath/rails/refresh_token_authentication.rb +28 -0
- data/app/services/stormpath/rails/resend_email_verification.rb +33 -0
- data/app/services/stormpath/rails/send_password_reset_email.rb +33 -0
- data/app/services/stormpath/rails/token_cookie_setter.rb +84 -0
- data/app/services/stormpath/rails/verify_email_token.rb +27 -0
- data/app/views/{passwords/forgot_change.html.erb → stormpath/rails/change_password/new.html.erb} +4 -10
- data/app/views/{passwords/forgot.html.erb → stormpath/rails/forgot_password/new.html.erb} +14 -4
- data/app/views/{layouts → stormpath/rails/layouts}/stormpath.html.erb +3 -3
- data/app/views/stormpath/rails/login/_form.html.erb +45 -0
- data/app/views/stormpath/rails/login/new.html.erb +12 -0
- data/app/views/stormpath/rails/register/_form.html.erb +19 -0
- data/app/views/{users → stormpath/rails/register}/new.html.erb +3 -3
- data/app/views/stormpath/rails/shared/_input.html.erb +15 -0
- data/app/views/stormpath/rails/verify_email/new.html.erb +49 -0
- data/bin/console +3 -3
- data/bin/rails +1 -1
- data/bin/rake +2 -2
- data/bin/rspec +2 -2
- data/config/initializers/assets.rb +3 -1
- data/lib/generators/stormpath/install/install_generator.rb +1 -92
- data/lib/generators/stormpath/install/templates/default_config.yml +229 -0
- data/lib/generators/stormpath/views/USAGE +0 -0
- data/lib/generators/stormpath/views/views_generator.rb +2 -2
- data/lib/stormpath/rails/client.rb +8 -85
- data/lib/stormpath/rails/config/account_store_verification.rb +45 -0
- data/lib/stormpath/rails/config/application_resolution.rb +76 -0
- data/lib/stormpath/rails/config/dynamic_configuration.rb +50 -0
- data/lib/stormpath/rails/config/read_file.rb +35 -0
- data/lib/stormpath/rails/configuration.rb +30 -35
- data/lib/stormpath/rails/content_type_negotiator.rb +50 -0
- data/lib/stormpath/rails/controller.rb +36 -5
- data/lib/stormpath/rails/errors/invalid_sptoken_error.rb +9 -0
- data/lib/stormpath/rails/errors/no_sptoken_error.rb +13 -0
- data/lib/stormpath/rails/router.rb +75 -0
- data/lib/stormpath/rails/routing_constraint.rb +9 -0
- data/lib/stormpath/rails/social.rb +6 -6
- data/lib/stormpath/rails/version.rb +2 -1
- data/lib/stormpath/rails.rb +9 -19
- data/lib/stormpath-rails.rb +1 -0
- data/stormpath-rails.gemspec +13 -11
- metadata +96 -54
- data/app/controllers/stormpath/rails/omniauth_controller.rb +0 -11
- data/app/controllers/stormpath/rails/passwords_controller.rb +0 -56
- data/app/controllers/stormpath/rails/sessions_controller.rb +0 -52
- data/app/controllers/stormpath/rails/users_controller.rb +0 -65
- data/app/views/passwords/edit.html.erb +0 -0
- data/app/views/passwords/email_sent.html.erb +0 -15
- data/app/views/passwords/forgot_change_failed.html.erb +0 -14
- data/app/views/passwords/forgot_complete.html.erb +0 -19
- data/app/views/sessions/_facebook_login_form.erb +0 -31
- data/app/views/sessions/_form.html.erb +0 -31
- data/app/views/sessions/_google_login_form.html.erb +0 -3
- data/app/views/sessions/_social_auth.html.erb +0 -7
- data/app/views/sessions/new.html.erb +0 -21
- data/app/views/users/_form.html.erb +0 -43
- data/app/views/users/verification_complete.html.erb +0 -20
- data/app/views/users/verification_email_sent.html.erb +0 -15
- data/app/views/users/verification_failed.html.erb +0 -14
- data/app/views/users/verification_resend.html.erb +0 -14
- data/config/routes.rb +0 -16
- data/lib/generators/stormpath/install/templates/db/migrate/add_stormpath_to_users.rb +0 -21
- data/lib/generators/stormpath/install/templates/db/migrate/create_users.rb +0 -12
- data/lib/generators/stormpath/install/templates/stormpath.rb +0 -4
- data/lib/generators/stormpath/install/templates/user.rb +0 -3
- data/lib/generators/stormpath/routes/routes_generator.rb +0 -23
- data/lib/generators/stormpath/routes/templates/routes.rb +0 -5
- data/lib/stormpath/rails/account.rb +0 -6
- data/lib/stormpath/rails/account_status.rb +0 -28
- data/lib/stormpath/rails/authentication.rb +0 -72
- data/lib/stormpath/rails/authentication_status.rb +0 -22
- data/lib/stormpath/rails/session.rb +0 -37
- data/lib/stormpath/rails/user.rb +0 -25
- data/lib/stormpath/rails/user_config/api_key.rb +0 -17
- data/lib/stormpath/rails/user_config/application.rb +0 -12
- data/lib/stormpath/rails/user_config/facebook.rb +0 -16
- data/lib/stormpath/rails/user_config/forgot_password.rb +0 -12
- data/lib/stormpath/rails/user_config/google.rb +0 -16
- data/lib/stormpath/rails/user_config/id_site.rb +0 -13
- data/lib/stormpath/rails/user_config/login.rb +0 -13
- data/lib/stormpath/rails/user_config/logout.rb +0 -13
- data/lib/stormpath/rails/user_config/register.rb +0 -13
- data/lib/stormpath/rails/user_config/verify_email.rb +0 -14
- data/lib/stormpath/testing/helpers.rb +0 -49
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
class AuthenticationStatus
|
|
4
|
-
|
|
5
|
-
def initialize(response)
|
|
6
|
-
@response = response
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def success?
|
|
10
|
-
@response.instance_of? Stormpath::Authentication::AuthenticationResult
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def error_message
|
|
14
|
-
if @response.instance_of? String
|
|
15
|
-
return @response
|
|
16
|
-
else
|
|
17
|
-
''
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module Session
|
|
4
|
-
extend ActiveSupport::Concern
|
|
5
|
-
|
|
6
|
-
included do
|
|
7
|
-
helper_method :current_user, :signed_in?, :signed_out?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
private
|
|
11
|
-
|
|
12
|
-
def initialize_session(user)
|
|
13
|
-
session[:user_id] = user.id
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def reset_session
|
|
17
|
-
session[:user_id] = nil
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def logout
|
|
21
|
-
reset_session
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def signed_in?
|
|
25
|
-
!session[:user_id].nil?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def signed_out?
|
|
29
|
-
!signed_in?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def current_user
|
|
33
|
-
@current_user ||= configuration.user_model.find(session[:user_id]) if session[:user_id]
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
data/lib/stormpath/rails/user.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module User
|
|
4
|
-
extend ActiveSupport::Concern
|
|
5
|
-
|
|
6
|
-
included do
|
|
7
|
-
attr_accessor :password
|
|
8
|
-
|
|
9
|
-
validates :email, presence: true, uniqueness: true
|
|
10
|
-
validates_presence_of :given_name
|
|
11
|
-
validates_presence_of :surname
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module ClassMethods
|
|
15
|
-
def find_user(email)
|
|
16
|
-
find_by email: normalize_email(email)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def normalize_email(email)
|
|
20
|
-
email.to_s.downcase.gsub(/\s+/, "")
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class ApiKey
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :file, String
|
|
8
|
-
attribute :id, String
|
|
9
|
-
attribute :secret, String
|
|
10
|
-
|
|
11
|
-
def file_location_provided?
|
|
12
|
-
!self.file.nil?
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class Facebook
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :app_id, String
|
|
8
|
-
attribute :app_secret, String
|
|
9
|
-
|
|
10
|
-
def enabled?
|
|
11
|
-
!(self.app_id.blank? && self.app_secret.blank?)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class Google
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :client_id, String
|
|
8
|
-
attribute :client_secret, String
|
|
9
|
-
|
|
10
|
-
def enabled?
|
|
11
|
-
!(self.client_id.blank? && self.client_secret.blank?)
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class IdSite
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :enabled, Boolean, default: false
|
|
8
|
-
attribute :uri, String, default: '/redirect'
|
|
9
|
-
attribute :next_uri, String, default: '/'
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class Register
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :enabled, Boolean, default: true
|
|
8
|
-
attribute :uri, String, default: '/register'
|
|
9
|
-
attribute :next_uri, String, default: '/'
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Rails
|
|
3
|
-
module UserConfig
|
|
4
|
-
class VerifyEmail
|
|
5
|
-
include Virtus.model
|
|
6
|
-
|
|
7
|
-
attribute :enabled, Boolean, default: false
|
|
8
|
-
attribute :uri, String, default: '/verify'
|
|
9
|
-
attribute :next_uri, String
|
|
10
|
-
attribute :view, String
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
module Stormpath
|
|
2
|
-
module Testing
|
|
3
|
-
module Helpers
|
|
4
|
-
def sign_in
|
|
5
|
-
create_test_account
|
|
6
|
-
@controller.send(:authenticate, test_user)
|
|
7
|
-
@controller.send(:initialize_session, test_user)
|
|
8
|
-
test_user
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def create_test_account
|
|
12
|
-
create_store_mapping
|
|
13
|
-
@test_account_result ||= Stormpath::Rails::Client.create_stormpath_account(test_user)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def delete_test_account
|
|
17
|
-
if @test_account_result && @test_account_result.success?
|
|
18
|
-
@test_account_result.response.delete
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def test_user
|
|
23
|
-
factory = Stormpath::Rails.config.user_model.to_s.underscore.to_sym
|
|
24
|
-
@test_user ||= FactoryGirl.create(factory)
|
|
25
|
-
@test_user.attributes = @test_user.attributes.merge!("password" => @test_user.password)
|
|
26
|
-
@test_user
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def create_test_directory
|
|
30
|
-
unless @test_directory
|
|
31
|
-
@test_directory ||= Stormpath::Rails::Client.client.directories.create(name: 'test-directory')
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def delete_test_directory
|
|
36
|
-
@test_directory.delete if @test_directory
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def create_store_mapping
|
|
40
|
-
@store_mapping ||= Stormpath::Rails::Client.client.account_store_mappings.create(
|
|
41
|
-
application: Stormpath::Rails::Client.application,
|
|
42
|
-
account_store: create_test_directory,
|
|
43
|
-
is_default_account_store: true,
|
|
44
|
-
is_default_group_store: true
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|