devise_jwt_auth 0.1.4 → 0.2.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/README.md +1 -1
- data/app/controllers/devise_jwt_auth/application_controller.rb +11 -22
- data/app/controllers/devise_jwt_auth/concerns/resource_finder.rb +3 -7
- data/app/controllers/devise_jwt_auth/concerns/set_user_by_token.rb +22 -18
- data/app/controllers/devise_jwt_auth/confirmations_controller.rb +10 -19
- data/app/controllers/devise_jwt_auth/omniauth_callbacks_controller.rb +38 -46
- data/app/controllers/devise_jwt_auth/passwords_controller.rb +34 -36
- data/app/controllers/devise_jwt_auth/refresh_token_controller.rb +4 -1
- data/app/controllers/devise_jwt_auth/registrations_controller.rb +40 -21
- data/app/controllers/devise_jwt_auth/sessions_controller.rb +21 -21
- data/app/controllers/devise_jwt_auth/unlocks_controller.rb +5 -4
- data/app/models/devise_jwt_auth/concerns/active_record_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/confirmable_support.rb +7 -14
- data/app/models/devise_jwt_auth/concerns/mongoid_support.rb +3 -0
- data/app/models/devise_jwt_auth/concerns/tokens_serialization.rb +4 -1
- data/app/models/devise_jwt_auth/concerns/user.rb +18 -11
- data/app/models/devise_jwt_auth/concerns/user_omniauth_callbacks.rb +11 -3
- data/app/validators/devise_jwt_auth_email_validator.rb +12 -2
- data/app/views/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/lib/devise_jwt_auth/blacklist.rb +3 -1
- data/lib/devise_jwt_auth/controllers/url_helpers.rb +1 -2
- data/lib/devise_jwt_auth/engine.rb +4 -4
- data/lib/devise_jwt_auth/rails/routes.rb +35 -24
- data/lib/devise_jwt_auth/token_factory.rb +3 -2
- data/lib/devise_jwt_auth/url.rb +2 -4
- data/lib/devise_jwt_auth/version.rb +1 -1
- data/lib/generators/devise_jwt_auth/USAGE +1 -1
- data/lib/generators/devise_jwt_auth/install_generator.rb +7 -6
- data/lib/generators/devise_jwt_auth/install_generator_helpers.rb +27 -6
- data/lib/generators/devise_jwt_auth/install_mongoid_generator.rb +3 -2
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth.rb +6 -7
- data/lib/generators/devise_jwt_auth/templates/devise_jwt_auth_create_users.rb.erb +15 -11
- data/lib/generators/devise_jwt_auth/templates/user.rb.erb +2 -2
- data/test/controllers/custom/custom_confirmations_controller_test.rb +2 -2
- data/test/controllers/custom/custom_omniauth_callbacks_controller_test.rb +1 -1
- data/test/controllers/custom/custom_passwords_controller_test.rb +8 -8
- data/test/controllers/custom/custom_refresh_token_controller_test.rb +2 -3
- data/test/controllers/custom/custom_registrations_controller_test.rb +2 -2
- data/test/controllers/demo_group_controller_test.rb +0 -24
- data/test/controllers/demo_mang_controller_test.rb +4 -224
- data/test/controllers/demo_user_controller_test.rb +6 -432
- data/test/controllers/devise_jwt_auth/confirmations_controller_test.rb +5 -5
- data/test/controllers/devise_jwt_auth/omniauth_callbacks_controller_test.rb +9 -10
- data/test/controllers/devise_jwt_auth/passwords_controller_test.rb +34 -35
- data/test/controllers/devise_jwt_auth/refresh_token_controller_test.rb +8 -12
- data/test/controllers/devise_jwt_auth/registrations_controller_test.rb +12 -26
- data/test/controllers/devise_jwt_auth/sessions_controller_test.rb +32 -34
- data/test/controllers/devise_jwt_auth/unlocks_controller_test.rb +2 -2
- data/test/controllers/overrides/confirmations_controller_test.rb +1 -1
- data/test/controllers/overrides/passwords_controller_test.rb +1 -6
- data/test/controllers/overrides/refresh_token_controller_test.rb +1 -2
- data/test/controllers/overrides/registrations_controller_test.rb +1 -1
- data/test/dummy/app/controllers/custom/refresh_token_controller.rb +2 -1
- data/test/dummy/app/controllers/custom/registrations_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/confirmations_controller.rb +3 -16
- data/test/dummy/app/controllers/overrides/omniauth_callbacks_controller.rb +4 -4
- data/test/dummy/app/controllers/overrides/passwords_controller.rb +4 -16
- data/test/dummy/app/controllers/overrides/refresh_token_controller.rb +1 -1
- data/test/dummy/app/controllers/overrides/registrations_controller.rb +2 -2
- data/test/dummy/app/controllers/overrides/sessions_controller.rb +2 -2
- data/test/dummy/app/models/concerns/favorite_color.rb +11 -9
- data/test/dummy/config/application.rb +1 -0
- data/test/dummy/config/boot.rb +1 -1
- data/test/dummy/config/environments/development.rb +2 -2
- data/test/dummy/config/environments/test.rb +11 -7
- data/test/dummy/config/initializers/devise_jwt_auth.rb +1 -0
- data/test/dummy/config/initializers/figaro.rb +1 -1
- data/test/dummy/config/initializers/omniauth.rb +2 -2
- data/test/dummy/config/routes.rb +10 -8
- data/test/dummy/config.ru +2 -2
- data/test/dummy/db/migrate/20141222035835_devise_jwt_auth_create_only_email_users.rb +9 -9
- data/test/dummy/db/migrate/20190924101113_devise_jwt_auth_create_confirmable_users.rb +6 -5
- data/test/dummy/db/schema.rb +170 -170
- data/test/dummy/tmp/generators/app/models/user.rb +8 -0
- data/test/dummy/tmp/generators/config/initializers/devise_jwt_auth.rb +6 -7
- data/test/dummy/tmp/generators/db/migrate/{20200210193225_devise_jwt_auth_create_azpire_v1_human_resource_users.rb → 20220123023137_devise_jwt_auth_create_users.rb} +20 -17
- data/test/factories/users.rb +5 -3
- data/test/lib/devise_jwt_auth/blacklist_test.rb +2 -2
- data/test/lib/devise_jwt_auth/token_factory_test.rb +7 -7
- data/test/lib/generators/devise_jwt_auth/install_generator_test.rb +3 -20
- data/test/lib/generators/devise_jwt_auth/install_generator_with_namespace_test.rb +4 -21
- data/test/models/concerns/tokens_serialization_test.rb +68 -68
- data/test/models/user_test.rb +0 -38
- data/test/support/controllers/routes.rb +7 -5
- data/test/test_helper.rb +1 -1
- metadata +45 -71
- data/test/dummy/tmp/generators/app/models/azpire/v1/human_resource/user.rb +0 -9
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module Overrides
|
4
4
|
class RegistrationsController < DeviseJwtAuth::RegistrationsController
|
5
|
-
OVERRIDE_PROOF = '(^^,)'
|
5
|
+
OVERRIDE_PROOF = '(^^,)'
|
6
6
|
|
7
7
|
def update
|
8
8
|
if @resource
|
9
9
|
if @resource.update(account_update_params)
|
10
10
|
render json: {
|
11
11
|
status: 'success',
|
12
|
-
data:
|
12
|
+
data: @resource.as_json,
|
13
13
|
override_proof: OVERRIDE_PROOF
|
14
14
|
}
|
15
15
|
else
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Overrides
|
4
4
|
class SessionsController < DeviseJwtAuth::SessionsController
|
5
|
-
OVERRIDE_PROOF = '(^^,)'
|
5
|
+
OVERRIDE_PROOF = '(^^,)'
|
6
6
|
|
7
7
|
def create
|
8
8
|
@resource = resource_class.dta_find_by(email: resource_params[:email])
|
@@ -16,7 +16,7 @@ module Overrides
|
|
16
16
|
override_proof: OVERRIDE_PROOF
|
17
17
|
}.merge(auth_header)
|
18
18
|
|
19
|
-
elsif @resource &&
|
19
|
+
elsif @resource && !@resource.confirmed?
|
20
20
|
render json: {
|
21
21
|
success: false,
|
22
22
|
errors: [
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module FavoriteColor
|
2
4
|
extend ActiveSupport::Concern
|
3
5
|
|
@@ -5,15 +7,15 @@ module FavoriteColor
|
|
5
7
|
validates :operating_thetan, numericality: true, allow_nil: true
|
6
8
|
validate :ensure_correct_favorite_color
|
7
9
|
end
|
8
|
-
|
10
|
+
|
9
11
|
def ensure_correct_favorite_color
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
return unless favorite_color && (favorite_color != '')
|
13
|
+
|
14
|
+
return if ApplicationHelper::COLOR_NAMES.any? { |s| s.casecmp(favorite_color).zero? }
|
15
|
+
|
16
|
+
matches = ApplicationHelper::COLOR_SEARCH.search(favorite_color)
|
17
|
+
closest_match = matches.last[:string]
|
18
|
+
second_closest_match = matches[-2][:string]
|
19
|
+
errors.add(:favorite_color, "We've never heard of the color \"#{favorite_color}\". Did you mean \"#{closest_match}\"? Or perhaps \"#{second_closest_match}\"?")
|
18
20
|
end
|
19
21
|
end
|
data/test/dummy/config/boot.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
unless defined?(DEVISE_JWT_AUTH_ORM)
|
4
|
-
DEVISE_JWT_AUTH_ORM = (ENV[
|
4
|
+
DEVISE_JWT_AUTH_ORM = (ENV['DEVISE_JWT_AUTH_ORM'] || :active_record).to_sym
|
5
5
|
end
|
6
6
|
|
7
7
|
# Set up gems listed in the Gemfile.
|
@@ -19,7 +19,7 @@ Rails.application.configure do
|
|
19
19
|
config.action_mailer.raise_delivery_errors = true
|
20
20
|
|
21
21
|
# use mailcatcher for development
|
22
|
-
config.action_mailer.default_url_options = { host: 'devise-
|
22
|
+
config.action_mailer.default_url_options = { host: 'devise-jwt-auth.dev' }
|
23
23
|
config.action_mailer.delivery_method = :smtp
|
24
24
|
config.action_mailer.smtp_settings = { address: 'localhost', port: 1025 }
|
25
25
|
|
@@ -42,5 +42,5 @@ Rails.application.configure do
|
|
42
42
|
# Raises error for missing translations
|
43
43
|
# config.action_view.raise_on_missing_translations = true
|
44
44
|
|
45
|
-
OmniAuth.config.full_host = 'http://devise-
|
45
|
+
OmniAuth.config.full_host = 'http://devise-jwt-auth.dev'
|
46
46
|
end
|
@@ -15,13 +15,17 @@ Rails.application.configure do
|
|
15
15
|
config.eager_load = false
|
16
16
|
|
17
17
|
# Configure static asset server for tests with Cache-Control for performance.
|
18
|
-
Rails::VERSION::MAJOR == 5
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
if Rails::VERSION::MAJOR == 5
|
19
|
+
(config.public_file_server.enabled = true)
|
20
|
+
else
|
21
|
+
(config.serve_static_files = true)
|
22
|
+
end
|
23
|
+
|
24
|
+
if Rails::VERSION::MAJOR == 5
|
25
|
+
(config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' })
|
26
|
+
else
|
27
|
+
(config.static_cache_control = 'public, max-age=3600')
|
28
|
+
end
|
25
29
|
|
26
30
|
# Show full error reports and disable caching.
|
27
31
|
config.consider_all_requests_local = true
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
DeviseJwtAuth.setup do |config|
|
4
|
+
# TODO: Remove old config settings from DTA.
|
4
5
|
# By default the authorization headers will change after each request. The
|
5
6
|
# client is responsible for keeping track of the changing tokens. Change
|
6
7
|
# this to false to prevent the Authorization header from changing after
|
@@ -1,3 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
#Figaro.require("GITHUB_KEY", "GITHUB_SECRET", "FACEBOOK_KEY", "FACEBOOK_SECRET", "GOOGLE_KEY", "GOOGLE_SECRET", "APPLE_CLIENT_ID", "APPLE_TEAM_ID", "APPLE_KEY", "APPLE_PEM")
|
3
|
+
# 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,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
Rails.application.config.middleware.use OmniAuth::Builder do |
|
4
|
-
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'],
|
3
|
+
Rails.application.config.middleware.use OmniAuth::Builder do |_b|
|
4
|
+
provider :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: 'email,profile'
|
5
5
|
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET']
|
6
6
|
provider :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET']
|
7
7
|
provider :apple, ENV['APPLE_CLIENT_ID'], '', { scope: 'email name', team_id: ENV['APPLE_TEAM_ID'], key_id: ENV['APPLE_KEY'], pem: ENV['APPLE_PEM'] }
|
data/test/dummy/config/routes.rb
CHANGED
@@ -32,14 +32,14 @@ Rails.application.routes.draw do
|
|
32
32
|
# test namespacing with not created devise mapping
|
33
33
|
namespace :api_v2, defaults: { format: :json } do
|
34
34
|
mount_devise_jwt_auth_for 'ScopedUser',
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
at: 'auth',
|
36
|
+
controllers: {
|
37
|
+
omniauth_callbacks: 'api_v2/omniauth_callbacks',
|
38
|
+
sessions: 'api_v2/sessions',
|
39
|
+
registrations: 'api_v2/registrations',
|
40
|
+
confirmations: 'api_v2/confirmations',
|
41
|
+
passwords: 'api_v2/passwords'
|
42
|
+
}
|
43
43
|
end
|
44
44
|
|
45
45
|
# this route will authorize visitors using the User class
|
@@ -54,4 +54,6 @@ Rails.application.routes.draw do
|
|
54
54
|
|
55
55
|
# we need a route for omniauth_callback_controller to redirect to in sameWindow case
|
56
56
|
get 'auth_origin', to: 'auth_origin#redirected'
|
57
|
+
|
58
|
+
# get 'omniauth/facebook', to: 'omni#facebook'
|
57
59
|
end
|
data/test/dummy/config.ru
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# This file is used by Rack-based servers to start the application.
|
4
4
|
|
5
|
-
require ::File.expand_path('
|
5
|
+
require ::File.expand_path('config/environment', __dir__)
|
6
6
|
run Rails.application
|
7
7
|
|
8
8
|
# allow cross origin requests
|
@@ -12,7 +12,7 @@ use Rack::Cors do
|
|
12
12
|
origins '*'
|
13
13
|
resource '*',
|
14
14
|
headers: :any,
|
15
|
-
expose: [
|
15
|
+
expose: %w[access-token],
|
16
16
|
methods: %i[get post options delete put]
|
17
17
|
end
|
18
18
|
end
|
@@ -13,17 +13,17 @@ class DeviseJwtAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
|
|
13
13
|
t.string :encrypted_password, null: false, default: ''
|
14
14
|
|
15
15
|
## Recoverable
|
16
|
-
#t.string :reset_password_token
|
17
|
-
#t.datetime :reset_password_sent_at
|
16
|
+
# t.string :reset_password_token
|
17
|
+
# t.datetime :reset_password_sent_at
|
18
18
|
|
19
19
|
## Rememberable
|
20
|
-
#t.datetime :remember_created_at
|
20
|
+
# t.datetime :remember_created_at
|
21
21
|
|
22
22
|
## Confirmable
|
23
|
-
#t.string :confirmation_token
|
24
|
-
#t.datetime :confirmed_at
|
25
|
-
#t.datetime :confirmation_sent_at
|
26
|
-
#t.string :unconfirmed_email # Only if using reconfirmable
|
23
|
+
# t.string :confirmation_token
|
24
|
+
# t.datetime :confirmed_at
|
25
|
+
# t.datetime :confirmation_sent_at
|
26
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
27
27
|
|
28
28
|
## Lockable
|
29
29
|
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
|
@@ -47,8 +47,8 @@ class DeviseJwtAuthCreateOnlyEmailUsers < ActiveRecord::Migration[4.2]
|
|
47
47
|
end
|
48
48
|
|
49
49
|
add_index :only_email_users, :email
|
50
|
-
add_index :only_email_users, [:uid, :provider],
|
51
|
-
#add_index :only_email_users, :reset_password_token, :unique => true
|
50
|
+
add_index :only_email_users, [:uid, :provider], unique: true
|
51
|
+
# add_index :only_email_users, :reset_password_token, :unique => true
|
52
52
|
# add_index :only_email_users, :confirmation_token, :unique => true
|
53
53
|
# add_index :only_email_users, :unlock_token, :unique => true
|
54
54
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
class DeviseJwtAuthCreateConfirmableUsers < ActiveRecord::Migration[5.2]
|
2
4
|
def change
|
3
|
-
|
4
5
|
create_table(:confirmable_users) do |t|
|
5
6
|
## Required
|
6
|
-
t.string :provider, :
|
7
|
-
t.string :uid, :
|
7
|
+
t.string :provider, null: false, default: 'email'
|
8
|
+
t.string :uid, null: false, default: ''
|
8
9
|
|
9
10
|
## Database authenticatable
|
10
|
-
t.string :encrypted_password, :
|
11
|
+
t.string :encrypted_password, null: false, default: ''
|
11
12
|
|
12
13
|
## Recoverable
|
13
14
|
t.string :reset_password_token
|
14
15
|
t.datetime :reset_password_sent_at
|
15
|
-
t.boolean :allow_password_change, :
|
16
|
+
t.boolean :allow_password_change, default: false
|
16
17
|
|
17
18
|
## Rememberable
|
18
19
|
t.datetime :remember_created_at
|