Class: Minato::Rails::Auth::User
- Inherits:
-
Object
- Object
- Minato::Rails::Auth::User
- Defined in:
- lib/minato/rails/auth/user.rb
Instance Attribute Summary collapse
-
#token_payload_obj ⇒ Object
readonly
Returns the value of attribute token_payload_obj.
-
#token_payload_raw ⇒ Object
readonly
Returns the value of attribute token_payload_raw.
Instance Method Summary collapse
- #auth_password? ⇒ Boolean
- #auth_provider ⇒ Object
- #auth_sso? ⇒ Boolean
- #human? ⇒ Boolean
- #identity ⇒ Object
- #impersonated? ⇒ Boolean
- #impersonator_identity ⇒ Object
-
#initialize(token_payload) ⇒ User
constructor
A new instance of User.
- #machine? ⇒ Boolean
- #subject ⇒ Object
Constructor Details
#initialize(token_payload) ⇒ User
Returns a new instance of User.
11 12 13 14 |
# File 'lib/minato/rails/auth/user.rb', line 11 def initialize(token_payload) @token_payload_raw = token_payload @token_payload_obj = ObjectHash.new(token_payload) end |
Instance Attribute Details
#token_payload_obj ⇒ Object (readonly)
Returns the value of attribute token_payload_obj.
9 10 11 |
# File 'lib/minato/rails/auth/user.rb', line 9 def token_payload_obj @token_payload_obj end |
#token_payload_raw ⇒ Object (readonly)
Returns the value of attribute token_payload_raw.
9 10 11 |
# File 'lib/minato/rails/auth/user.rb', line 9 def token_payload_raw @token_payload_raw end |
Instance Method Details
#auth_password? ⇒ Boolean
28 29 30 |
# File 'lib/minato/rails/auth/user.rb', line 28 def auth_password? authentication_method? 'password' end |
#auth_provider ⇒ Object
32 33 34 35 36 |
# File 'lib/minato/rails/auth/user.rb', line 32 def auth_provider return unless auth_sso? authentication_method('oidc')['provider'] end |
#auth_sso? ⇒ Boolean
24 25 26 |
# File 'lib/minato/rails/auth/user.rb', line 24 def auth_sso? authentication_method? 'oidc' end |
#human? ⇒ Boolean
16 17 18 |
# File 'lib/minato/rails/auth/user.rb', line 16 def human? session_obj&.identity.present? end |
#identity ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/minato/rails/auth/user.rb', line 38 def identity return nil if machine? return impersonator_identity unless impersonated? session_obj.identity..impersonated_identity end |
#impersonated? ⇒ Boolean
54 55 56 57 58 |
# File 'lib/minato/rails/auth/user.rb', line 54 def impersonated? return false if machine? session_obj.identity.&.impersonated_identity.present? end |
#impersonator_identity ⇒ Object
46 47 48 |
# File 'lib/minato/rails/auth/user.rb', line 46 def impersonator_identity session_obj.identity end |
#machine? ⇒ Boolean
20 21 22 |
# File 'lib/minato/rails/auth/user.rb', line 20 def machine? !human? end |
#subject ⇒ Object
50 51 52 |
# File 'lib/minato/rails/auth/user.rb', line 50 def subject @token_payload_obj.sub end |