nyauth 0.5.0 → 0.6.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/concerns/nyauth/client_concern.rb +1 -0
- data/app/controllers/concerns/nyauth/session_concern.rb +13 -2
- data/app/controllers/nyauth/base_controller.rb +7 -0
- data/app/controllers/nyauth/confirmation_requests_controller.rb +2 -3
- data/app/controllers/nyauth/confirmations_controller.rb +2 -3
- data/app/controllers/nyauth/passwords_controller.rb +1 -5
- data/app/controllers/nyauth/registrations_controller.rb +1 -4
- data/app/controllers/nyauth/reset_password_requests_controller.rb +1 -4
- data/app/controllers/nyauth/reset_passwords_controller.rb +1 -4
- data/app/controllers/nyauth/sessions_controller.rb +2 -5
- data/app/helpers/nyauth/application_helper.rb +4 -0
- data/app/models/concerns/nyauth/authenticatable.rb +1 -1
- data/lib/generators/nyauth/templates/nyauth_install_initializer.rb +1 -0
- data/lib/nyauth/configuration.rb +3 -1
- data/lib/nyauth/middleware.rb +1 -0
- data/lib/nyauth/nyan.rb +1 -0
- data/lib/nyauth/session_serializer.rb +2 -1
- data/lib/nyauth/version.rb +1 -1
- data/spec/dummy/config/initializers/nyauth.rb +1 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +1279 -0
- data/spec/dummy/log/test.log +5024 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/1SgsiPCC0_OqwmFFIeO-NDjvo5Cj0FU348WFcY_2j6c.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/2NBqGhntP-vkXcqELAsDTzmnheGw93xJN_VGA0pgaRE.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/9i_17ApHgLHXHlwXbU9QEfNrNMgVPjAoAk0EfGS-cWw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/CNXGLOU1u3FFzGFDMg_4iNcdCDd2iAmoOaiRROni8Tk.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/IWK3eA3Xg7xhMT1dZKZVm3upMCwIJ0SQ9OSvgr5EQSQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/M-01bce3-wk7ejaA8vPEwUWCLHoDDBrUXjHsxjmvj5M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/M7oa-ssP0ThBOv3o2FcsdNgXY3vxnpfs-rW3tIOkwkU.cache +2 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/MjbfHEk5fL4HFRCXVVkwYMHu5guRcO-FGLFU485dMV8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/NeJ0a8W4OrDx7L-0PPkc484TRX7ReOk8iMHFUA96r8c.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +3 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/PefL8G86ueryC3XcvIG9eI1OB29lP3VNB-BdcF-kisA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/RDcmknHrxZY-Yz12bLt6TFfj9Wn_F4np3vZaysEl0nQ.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/TCPOmqTgyNFovZmHXHUPPumf8jHDXCMHIu91bxyq_qM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/TbwAyWIHAKNshn19Q4B2Ukz3T5mduRykZjm3fove1I0.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/cD-xX85wEbUx0FzXhj4CwiGLwYA65KFOABy8pO7xa2s.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/jd_OAtZU3_tKwIEXznG0fpajbw6aSC6FZbPI4_OI3Qs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/q67E19uacbtvHmcq693Fj-LzCJhNHm5-fXCKhuCOqos.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/qNepDmbIi_nFZX0KJF-zUvTl9CohiLBxTD-P97k1Cs4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/rZS2dSuZR3CGbChyMtQnJmfrHS-eYItGdlz8HLRVRP4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/t1OSyz8ZOkqn7HP_G1--JL_iLGWUQs2V9NzsmGgQbuc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/vwm1k9Bq-HwABJMegaJmccXR8JXBcp7a46peIjalZug.cache +1 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/v3.0/xNxWjlD2nQ_nHrl6FvGZ5mhn4F5A5XJAlz029Se49y4.cache +2 -0
- metadata +49 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5575c6f6f641ecad045a93b77c40faec4c42ab70
|
|
4
|
+
data.tar.gz: 4a052e63f7175875367985d4b5704c34a2df1eda
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6d7949a04cca35acfa2e8a15082c245d347c50ab7bad3d064d5c065b5a1fce1fdb90690e49b3678b831a867e3a2277f43475facbd9e98b47a48861b13f3c061f
|
|
7
|
+
data.tar.gz: 3b57115fe59252703f48bedf7a7d48232b20e2a514c55b949c4711d41667c21fad63962bbea91aad14e26f85480deccd38eff6b59db6d348da5630bfb6ab33fc
|
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Simple & modulable authentication gem
|
|
|
9
9
|
```ruby
|
|
10
10
|
class ApplicationController < ActionController::Base
|
|
11
11
|
include Nyauth::ControllerConcern
|
|
12
|
-
before_action -> { require_authentication! as:
|
|
12
|
+
before_action -> { require_authentication! as: nyauth_client_name }
|
|
13
13
|
end
|
|
14
14
|
```
|
|
15
15
|
|
|
@@ -13,7 +13,7 @@ module Nyauth
|
|
|
13
13
|
# sign_in(client)
|
|
14
14
|
def sign_in(client)
|
|
15
15
|
return unless client
|
|
16
|
-
|
|
16
|
+
store_signed_in_status(client)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# ex.)
|
|
@@ -28,6 +28,11 @@ module Nyauth
|
|
|
28
28
|
# sign_out
|
|
29
29
|
def sign_out
|
|
30
30
|
reset_session
|
|
31
|
+
|
|
32
|
+
if Nyauth.configuration.use_cookie_auth
|
|
33
|
+
# ex.) cookies.signed[:user_id]
|
|
34
|
+
cookies.delete :nyauth_cookie_auth
|
|
35
|
+
end
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
# ex.)
|
|
@@ -36,6 +41,7 @@ module Nyauth
|
|
|
36
41
|
options.reverse_merge!(as: :user)
|
|
37
42
|
return if self.class.allow_actions == :all
|
|
38
43
|
return if self.class.allow_actions.present? && request[:action].to_sym.in?(self.class.allow_actions)
|
|
44
|
+
|
|
39
45
|
unless signed_in?(options)
|
|
40
46
|
session["#{options[:as]}_return_to"] = request.url if request.get?
|
|
41
47
|
redirect_to new_session_path_for(options[:as])
|
|
@@ -47,8 +53,13 @@ module Nyauth
|
|
|
47
53
|
nyauth_nyan.session.fetch(options[:as])
|
|
48
54
|
end
|
|
49
55
|
|
|
50
|
-
def
|
|
56
|
+
def store_signed_in_status(client)
|
|
51
57
|
nyauth_nyan.session.store(client, client.class.name.demodulize.underscore)
|
|
58
|
+
|
|
59
|
+
if Nyauth.configuration.use_cookie_auth
|
|
60
|
+
# ex.) cookies.signed[:user_id]
|
|
61
|
+
cookies.signed[:nyauth_cookie_auth] = "#{client.class.name.demodulize.underscore}:#{client.id}"
|
|
62
|
+
end
|
|
52
63
|
end
|
|
53
64
|
|
|
54
65
|
private
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class ConfirmationRequestsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class ConfirmationRequestsController < Nyauth::BaseController
|
|
4
3
|
allow_everyone
|
|
5
4
|
self.responder = Nyauth::AppResponder
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
before_action :set_service
|
|
8
7
|
after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }
|
|
9
8
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class ConfirmationsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class ConfirmationsController < Nyauth::BaseController
|
|
4
3
|
allow_everyone
|
|
5
4
|
self.responder = ConfirmationResponder
|
|
6
|
-
|
|
5
|
+
|
|
7
6
|
before_action :set_client
|
|
8
7
|
|
|
9
8
|
def update
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class PasswordsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class PasswordsController < Nyauth::BaseController
|
|
4
3
|
before_action -> { require_authentication! as: nyauth_client_name }
|
|
5
|
-
|
|
6
|
-
self.responder = Nyauth::AppResponder
|
|
7
|
-
respond_to :html, :json
|
|
8
4
|
before_action :set_client
|
|
9
5
|
|
|
10
6
|
def edit
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class RegistrationsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class RegistrationsController < Nyauth::BaseController
|
|
4
3
|
allow_everyone
|
|
5
|
-
self.responder = Nyauth::AppResponder
|
|
6
|
-
respond_to :html, :json
|
|
7
4
|
before_action :set_service
|
|
8
5
|
|
|
9
6
|
def new
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class ResetPasswordRequestsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class ResetPasswordRequestsController < Nyauth::BaseController
|
|
4
3
|
allow_everyone
|
|
5
|
-
self.responder = Nyauth::AppResponder
|
|
6
|
-
respond_to :html, :json
|
|
7
4
|
before_action :set_service
|
|
8
5
|
after_action :send_mail, only: [:create], if: -> { @service.errors.blank? }
|
|
9
6
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class ResetPasswordsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
2
|
+
class ResetPasswordsController < Nyauth::BaseController
|
|
4
3
|
allow_everyone
|
|
5
|
-
self.responder = Nyauth::AppResponder
|
|
6
|
-
respond_to :html, :json
|
|
7
4
|
before_action :set_client
|
|
8
5
|
|
|
9
6
|
def edit
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
module Nyauth
|
|
2
|
-
class SessionsController <
|
|
3
|
-
include Nyauth::ControllerConcern
|
|
4
|
-
before_action -> { require_authentication! as: nyauth_client_name }
|
|
2
|
+
class SessionsController < Nyauth::BaseController
|
|
5
3
|
allow_everyone only: [:new, :create]
|
|
6
|
-
|
|
7
|
-
respond_to :html, :json
|
|
4
|
+
before_action -> { require_authentication! as: nyauth_client_name }
|
|
8
5
|
before_action :set_service
|
|
9
6
|
|
|
10
7
|
def new
|
|
@@ -14,6 +14,7 @@ module Nyauth
|
|
|
14
14
|
def detect_url_helper(feature, nyauth_client_name, *args)
|
|
15
15
|
@__methods ||= Nyauth::Engine.routes.url_helpers.instance_methods + Rails.application.routes.url_helpers.instance_methods
|
|
16
16
|
@__candidates ||= @__methods.reject{|m| m =~ /\A(:?rails_|_)/}.map(&:to_s)
|
|
17
|
+
|
|
17
18
|
if respond_to?(:nyauth) && nyauth_client_name.to_sym == :user
|
|
18
19
|
# mounted as nyauth
|
|
19
20
|
detect_url_helper_for_nyauth(feature, *args)
|
|
@@ -25,6 +26,7 @@ module Nyauth
|
|
|
25
26
|
def detect_url_helper_for_nyauth(feature, *args)
|
|
26
27
|
path = @__candidates.grep(/\A#{feature}_path\z/).first
|
|
27
28
|
return nil unless path
|
|
29
|
+
|
|
28
30
|
nyauth.__send__(path, *args)
|
|
29
31
|
end
|
|
30
32
|
|
|
@@ -34,7 +36,9 @@ module Nyauth
|
|
|
34
36
|
else
|
|
35
37
|
path = @__candidates.grep(/\A#{nyauth_client_name}_#{feature}_path\z/).first
|
|
36
38
|
end
|
|
39
|
+
|
|
37
40
|
return nil unless path
|
|
41
|
+
|
|
38
42
|
main_app.__send__(path, *args)
|
|
39
43
|
end
|
|
40
44
|
|
|
@@ -4,7 +4,6 @@ module Nyauth
|
|
|
4
4
|
include Nyauth::PasswordDigestAbility
|
|
5
5
|
include Nyauth::ResetPasswordAbility
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
included do
|
|
9
8
|
validates :email, presence: true
|
|
10
9
|
end
|
|
@@ -13,6 +12,7 @@ module Nyauth
|
|
|
13
12
|
def authenticate(given_email, given_password)
|
|
14
13
|
record = where(email: given_email).last
|
|
15
14
|
return nil unless record
|
|
15
|
+
|
|
16
16
|
record.verify_password?(given_password) ? record : nil
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -3,6 +3,7 @@ Nyauth.configure do |config|
|
|
|
3
3
|
config.confirmation_expire_limit = 1.hour
|
|
4
4
|
config.reset_password_expire_limit = 1.hour
|
|
5
5
|
config.mail_delivery_method = :deliver_now
|
|
6
|
+
config.use_cookie_auth = false
|
|
6
7
|
config.redirect_path do |urls|
|
|
7
8
|
# config.redirect_path_after_sign_in = -> (client_name) {
|
|
8
9
|
# if client_name == :admin
|
data/lib/nyauth/configuration.rb
CHANGED
|
@@ -14,7 +14,8 @@ module Nyauth
|
|
|
14
14
|
:password_minium,
|
|
15
15
|
:password_digest_stretches,
|
|
16
16
|
:encryption_secret,
|
|
17
|
-
:mail_delivery_method
|
|
17
|
+
:mail_delivery_method,
|
|
18
|
+
:use_cookie_auth
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def initialize
|
|
@@ -32,6 +33,7 @@ module Nyauth
|
|
|
32
33
|
@password_digest_stretches = 1000
|
|
33
34
|
@encryption_secret = ENV['NYAUTH_ENCRYPTION_SECRET']
|
|
34
35
|
@mail_delivery_method = :deliver_now
|
|
36
|
+
@use_cookie_auth = false
|
|
35
37
|
@redirect_path_block = Proc.new {}
|
|
36
38
|
end
|
|
37
39
|
|
data/lib/nyauth/middleware.rb
CHANGED
data/lib/nyauth/nyan.rb
CHANGED
|
@@ -19,6 +19,7 @@ module Nyauth
|
|
|
19
19
|
|
|
20
20
|
def store(client, scope)
|
|
21
21
|
return unless client
|
|
22
|
+
|
|
22
23
|
session[key_for(scope)] = serialize(client)
|
|
23
24
|
end
|
|
24
25
|
|
|
@@ -35,7 +36,7 @@ module Nyauth
|
|
|
35
36
|
!!session[key_for(scope)]
|
|
36
37
|
end
|
|
37
38
|
|
|
38
|
-
def delete(scope
|
|
39
|
+
def delete(scope)
|
|
39
40
|
session.delete(key_for(scope))
|
|
40
41
|
end
|
|
41
42
|
|
data/lib/nyauth/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
|
Binary file
|