stormpath-rails 1.1.2.beta → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rspec +1 -1
  4. data/.rubocop.yml +22 -0
  5. data/.travis.yml +6 -3
  6. data/Gemfile +10 -3
  7. data/README.md +139 -142
  8. data/Rakefile +9 -9
  9. data/app/assets/stylesheets/stormpath.css.scss +3 -2
  10. data/app/controllers/stormpath/rails/base_controller.rb +25 -6
  11. data/app/controllers/stormpath/rails/change_password/create_controller.rb +68 -0
  12. data/app/controllers/stormpath/rails/change_password/new_controller.rb +38 -0
  13. data/app/controllers/stormpath/rails/forgot_password/create_controller.rb +37 -0
  14. data/app/controllers/stormpath/rails/forgot_password/new_controller.rb +14 -0
  15. data/app/controllers/stormpath/rails/login/create_controller.rb +60 -0
  16. data/app/controllers/stormpath/rails/login/new_controller.rb +20 -0
  17. data/app/controllers/stormpath/rails/logout/create_controller.rb +61 -0
  18. data/app/controllers/stormpath/rails/oauth2/create_controller.rb +82 -0
  19. data/app/controllers/stormpath/rails/oauth2/new_controller.rb +11 -0
  20. data/app/controllers/stormpath/rails/profile/show_controller.rb +15 -0
  21. data/app/controllers/stormpath/rails/register/create_controller.rb +86 -0
  22. data/app/controllers/stormpath/rails/register/new_controller.rb +20 -0
  23. data/app/controllers/stormpath/rails/verify_email/create_controller.rb +37 -0
  24. data/app/controllers/stormpath/rails/verify_email/show_controller.rb +51 -0
  25. data/app/forms/stormpath/rails/login_form.rb +60 -0
  26. data/app/forms/stormpath/rails/registration_form.rb +106 -0
  27. data/app/forms/stormpath/rails/registration_form_fields.rb +71 -0
  28. data/app/helpers/social_helper.rb +2 -1
  29. data/app/serializers/stormpath/rails/account_serializer.rb +32 -0
  30. data/app/serializers/stormpath/rails/form_serializer.rb +37 -0
  31. data/app/serializers/stormpath/rails/login_new_serializer.rb +11 -0
  32. data/app/serializers/stormpath/rails/profile_serializer.rb +71 -0
  33. data/app/serializers/stormpath/rails/registration_form_serializer.rb +11 -0
  34. data/app/services/stormpath/rails/account_from_access_token/local_account_resolution.rb +48 -0
  35. data/app/services/stormpath/rails/account_from_access_token/stormpath_account_resolution.rb +27 -0
  36. data/app/services/stormpath/rails/account_from_access_token.rb +33 -0
  37. data/app/services/stormpath/rails/account_login.rb +28 -0
  38. data/app/services/stormpath/rails/account_login_with_stormpath_token.rb +32 -0
  39. data/app/services/stormpath/rails/client_credentials_authentication.rb +40 -0
  40. data/app/services/stormpath/rails/controller_authentication/from_basic_auth.rb +45 -0
  41. data/app/services/stormpath/rails/controller_authentication/from_bearer_auth.rb +34 -0
  42. data/app/services/stormpath/rails/controller_authentication/from_cookies.rb +71 -0
  43. data/app/services/stormpath/rails/controller_authentication.rb +44 -0
  44. data/app/services/stormpath/rails/delete_access_token.rb +48 -0
  45. data/app/services/stormpath/rails/delete_refresh_token.rb +11 -0
  46. data/app/services/stormpath/rails/forgot_password_token_verification.rb +31 -0
  47. data/app/services/stormpath/rails/password_change.rb +17 -0
  48. data/app/services/stormpath/rails/refresh_token_authentication.rb +28 -0
  49. data/app/services/stormpath/rails/resend_email_verification.rb +33 -0
  50. data/app/services/stormpath/rails/send_password_reset_email.rb +33 -0
  51. data/app/services/stormpath/rails/token_cookie_setter.rb +84 -0
  52. data/app/services/stormpath/rails/verify_email_token.rb +27 -0
  53. data/app/views/{passwords/forgot_change.html.erb → stormpath/rails/change_password/new.html.erb} +4 -10
  54. data/app/views/{passwords/forgot.html.erb → stormpath/rails/forgot_password/new.html.erb} +14 -4
  55. data/app/views/{layouts → stormpath/rails/layouts}/stormpath.html.erb +3 -3
  56. data/app/views/stormpath/rails/login/_form.html.erb +45 -0
  57. data/app/views/stormpath/rails/login/new.html.erb +12 -0
  58. data/app/views/stormpath/rails/register/_form.html.erb +19 -0
  59. data/app/views/{users → stormpath/rails/register}/new.html.erb +3 -3
  60. data/app/views/stormpath/rails/shared/_input.html.erb +15 -0
  61. data/app/views/stormpath/rails/verify_email/new.html.erb +49 -0
  62. data/bin/console +3 -3
  63. data/bin/rails +1 -1
  64. data/bin/rake +2 -2
  65. data/bin/rspec +2 -2
  66. data/config/initializers/assets.rb +3 -1
  67. data/lib/generators/stormpath/install/install_generator.rb +1 -92
  68. data/lib/generators/stormpath/install/templates/default_config.yml +229 -0
  69. data/lib/generators/stormpath/views/USAGE +0 -0
  70. data/lib/generators/stormpath/views/views_generator.rb +2 -2
  71. data/lib/stormpath/rails/client.rb +8 -85
  72. data/lib/stormpath/rails/config/account_store_verification.rb +45 -0
  73. data/lib/stormpath/rails/config/application_resolution.rb +76 -0
  74. data/lib/stormpath/rails/config/dynamic_configuration.rb +50 -0
  75. data/lib/stormpath/rails/config/read_file.rb +35 -0
  76. data/lib/stormpath/rails/configuration.rb +30 -35
  77. data/lib/stormpath/rails/content_type_negotiator.rb +50 -0
  78. data/lib/stormpath/rails/controller.rb +36 -5
  79. data/lib/stormpath/rails/errors/invalid_sptoken_error.rb +9 -0
  80. data/lib/stormpath/rails/errors/no_sptoken_error.rb +13 -0
  81. data/lib/stormpath/rails/router.rb +75 -0
  82. data/lib/stormpath/rails/routing_constraint.rb +9 -0
  83. data/lib/stormpath/rails/social.rb +6 -6
  84. data/lib/stormpath/rails/version.rb +2 -1
  85. data/lib/stormpath/rails.rb +9 -19
  86. data/lib/stormpath-rails.rb +1 -0
  87. data/stormpath-rails.gemspec +13 -11
  88. metadata +96 -54
  89. data/app/controllers/stormpath/rails/omniauth_controller.rb +0 -11
  90. data/app/controllers/stormpath/rails/passwords_controller.rb +0 -56
  91. data/app/controllers/stormpath/rails/sessions_controller.rb +0 -52
  92. data/app/controllers/stormpath/rails/users_controller.rb +0 -65
  93. data/app/views/passwords/edit.html.erb +0 -0
  94. data/app/views/passwords/email_sent.html.erb +0 -15
  95. data/app/views/passwords/forgot_change_failed.html.erb +0 -14
  96. data/app/views/passwords/forgot_complete.html.erb +0 -19
  97. data/app/views/sessions/_facebook_login_form.erb +0 -31
  98. data/app/views/sessions/_form.html.erb +0 -31
  99. data/app/views/sessions/_google_login_form.html.erb +0 -3
  100. data/app/views/sessions/_social_auth.html.erb +0 -7
  101. data/app/views/sessions/new.html.erb +0 -21
  102. data/app/views/users/_form.html.erb +0 -43
  103. data/app/views/users/verification_complete.html.erb +0 -20
  104. data/app/views/users/verification_email_sent.html.erb +0 -15
  105. data/app/views/users/verification_failed.html.erb +0 -14
  106. data/app/views/users/verification_resend.html.erb +0 -14
  107. data/config/routes.rb +0 -16
  108. data/lib/generators/stormpath/install/templates/db/migrate/add_stormpath_to_users.rb +0 -21
  109. data/lib/generators/stormpath/install/templates/db/migrate/create_users.rb +0 -12
  110. data/lib/generators/stormpath/install/templates/stormpath.rb +0 -4
  111. data/lib/generators/stormpath/install/templates/user.rb +0 -3
  112. data/lib/generators/stormpath/routes/routes_generator.rb +0 -23
  113. data/lib/generators/stormpath/routes/templates/routes.rb +0 -5
  114. data/lib/stormpath/rails/account.rb +0 -6
  115. data/lib/stormpath/rails/account_status.rb +0 -28
  116. data/lib/stormpath/rails/authentication.rb +0 -72
  117. data/lib/stormpath/rails/authentication_status.rb +0 -22
  118. data/lib/stormpath/rails/session.rb +0 -37
  119. data/lib/stormpath/rails/user.rb +0 -25
  120. data/lib/stormpath/rails/user_config/api_key.rb +0 -17
  121. data/lib/stormpath/rails/user_config/application.rb +0 -12
  122. data/lib/stormpath/rails/user_config/facebook.rb +0 -16
  123. data/lib/stormpath/rails/user_config/forgot_password.rb +0 -12
  124. data/lib/stormpath/rails/user_config/google.rb +0 -16
  125. data/lib/stormpath/rails/user_config/id_site.rb +0 -13
  126. data/lib/stormpath/rails/user_config/login.rb +0 -13
  127. data/lib/stormpath/rails/user_config/logout.rb +0 -13
  128. data/lib/stormpath/rails/user_config/register.rb +0 -13
  129. data/lib/stormpath/rails/user_config/verify_email.rb +0 -14
  130. 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
@@ -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,12 +0,0 @@
1
- module Stormpath
2
- module Rails
3
- module UserConfig
4
- class Application
5
- include Virtus.model
6
-
7
- attribute :name, String
8
- attribute :href, String
9
- end
10
- end
11
- end
12
- 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,12 +0,0 @@
1
- module Stormpath
2
- module Rails
3
- module UserConfig
4
- class ForgotPassword
5
- include Virtus.model
6
-
7
- attribute :enabled, Boolean, default: false
8
- attribute :uri, String, default: '/forgot'
9
- end
10
- end
11
- end
12
- 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 Login
5
- include Virtus.model
6
-
7
- attribute :enabled, Boolean, default: true
8
- attribute :uri, String, default: '/login'
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 Logout
5
- include Virtus.model
6
-
7
- attribute :enabled, Boolean, default: true
8
- attribute :uri, String, default: '/login'
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