Module: Wor::Authentication::Controller
- Defined in:
- lib/wor/authentication/controller.rb
Instance Method Summary collapse
- #authenticate_entity(params) ⇒ Object
- #authenticate_request ⇒ Object
- #authentication_token ⇒ Object
- #decoded_token ⇒ Object
- #entity_custom_validation_invalidate_all_value(entity) ⇒ Object
- #entity_custom_validation_renew_value(entity) ⇒ Object
- #entity_custom_validation_value(entity) ⇒ Object
- #entity_payload(entity) ⇒ Object
- #find_authenticable_entity(decoded_token) ⇒ Object
- #new_token_expiration_date ⇒ Object
-
#token_key ⇒ Object
Explain in README.
- #token_maximum_useful_date ⇒ Object
-
#token_renew_id ⇒ Object
Helpers which may be overrided.
Instance Method Details
#authenticate_entity(params) ⇒ Object
55 |
# File 'lib/wor/authentication/controller.rb', line 55 def authenticate_entity(params) {} end |
#authenticate_request ⇒ Object
7 8 9 10 |
# File 'lib/wor/authentication/controller.rb', line 7 def authenticate_request entity = find_authenticable_entity(decoded_token) decoded_token.validate!(entity_custom_validation_value(entity)) end |
#authentication_token ⇒ Object
32 33 34 |
# File 'lib/wor/authentication/controller.rb', line 32 def authentication_token request.headers['Authorization'].split(' ').last end |
#decoded_token ⇒ Object
12 13 14 |
# File 'lib/wor/authentication/controller.rb', line 12 def decoded_token @decoded_token ||= Wor::Authentication::TokenManager.new(token_key).decode(authentication_token) end |
#entity_custom_validation_invalidate_all_value(entity) ⇒ Object
44 45 46 |
# File 'lib/wor/authentication/controller.rb', line 44 def entity_custom_validation_invalidate_all_value(entity) nil end |
#entity_custom_validation_renew_value(entity) ⇒ Object
40 41 42 |
# File 'lib/wor/authentication/controller.rb', line 40 def entity_custom_validation_renew_value(entity) entity_custom_validation_value(entity) end |
#entity_custom_validation_value(entity) ⇒ Object
36 37 38 |
# File 'lib/wor/authentication/controller.rb', line 36 def entity_custom_validation_value(entity) nil end |
#entity_payload(entity) ⇒ Object
57 |
# File 'lib/wor/authentication/controller.rb', line 57 def entity_payload(entity) {} end |
#find_authenticable_entity(decoded_token) ⇒ Object
56 |
# File 'lib/wor/authentication/controller.rb', line 56 def find_authenticable_entity(decoded_token) {} end |
#new_token_expiration_date ⇒ Object
24 25 26 |
# File 'lib/wor/authentication/controller.rb', line 24 def new_token_expiration_date (Time.zone.now + 2.days).to_i end |
#token_key ⇒ Object
Explain in README
49 50 51 52 53 |
# File 'lib/wor/authentication/controller.rb', line 49 def token_key raise Wor::Authentication::Exceptions::SubclassMustImplementError unless defined?(Rails) raise Wor::Authentication::Exceptions::NoKeyProvidedError unless Rails.application.secrets.secret_key_base.present? Rails.application.secrets.secret_key_base end |
#token_maximum_useful_date ⇒ Object
28 29 30 |
# File 'lib/wor/authentication/controller.rb', line 28 def token_maximum_useful_date (Time.zone.now + 30.days).to_i end |
#token_renew_id ⇒ Object
Helpers which may be overrided
20 21 22 |
# File 'lib/wor/authentication/controller.rb', line 20 def token_renew_id Devise.friendly_token(32) end |