Module: Wor::Authentication::Controller

Defined in:
lib/wor/authentication/controller.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_entity(params) ⇒ Object



55
# File 'lib/wor/authentication/controller.rb', line 55

def authenticate_entity(params) {} end

#authenticate_requestObject



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_tokenObject



32
33
34
# File 'lib/wor/authentication/controller.rb', line 32

def authentication_token
  request.headers['Authorization'].split(' ').last
end

#decoded_tokenObject



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_dateObject



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_keyObject

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_dateObject



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_idObject

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