module Wor::Authentication::Controller

Public Instance Methods

authenticate_entity(_params) click to toggle source
# File lib/wor/authentication/controller.rb, line 64
def authenticate_entity(_params)
  {}
end
authenticate_request() click to toggle source
# File lib/wor/authentication/controller.rb, line 6
def authenticate_request
  entity = find_authenticable_entity(decoded_token)
  decoded_token.validate!(entity_custom_validation_value(entity))
end
authentication_token() click to toggle source
# File lib/wor/authentication/controller.rb, line 37
def authentication_token
  if request.headers['Authorization'].blank?
    raise Wor::Authentication::Exceptions::MissingAuthorizationHeader
  end
  request.headers['Authorization'].split(' ').last
end
current_entity() click to toggle source
# File lib/wor/authentication/controller.rb, line 25
def current_entity
  @current_entity ||= find_authenticable_entity(decoded_token)
end
decoded_token() click to toggle source
# File lib/wor/authentication/controller.rb, line 11
def decoded_token
  @decoded_token ||= Wor::Authentication::TokenManager.new(
    token_key
  ).decode(authentication_token)
end
entity_custom_validation_invalidate_all_value(_entity) click to toggle source
# File lib/wor/authentication/controller.rb, line 52
def entity_custom_validation_invalidate_all_value(_entity)
  nil
end
entity_custom_validation_renew_value(entity) click to toggle source
# File lib/wor/authentication/controller.rb, line 48
def entity_custom_validation_renew_value(entity)
  entity_custom_validation_value(entity)
end
entity_custom_validation_value(_entity) click to toggle source
# File lib/wor/authentication/controller.rb, line 44
def entity_custom_validation_value(_entity)
  nil
end
entity_payload(_entity) click to toggle source
# File lib/wor/authentication/controller.rb, line 72
def entity_payload(_entity)
  {}
end
find_authenticable_entity(_decoded_token) click to toggle source
# File lib/wor/authentication/controller.rb, line 68
def find_authenticable_entity(_decoded_token)
  {}
end
new_token_expiration_date() click to toggle source
# File lib/wor/authentication/controller.rb, line 17
def new_token_expiration_date
  Wor::Authentication.expiration_days.days.from_now.to_i
end
token_key() click to toggle source
# File lib/wor/authentication/controller.rb, line 56
def token_key
  raise Wor::Authentication::Exceptions::SubclassMustImplementError unless defined?(Rails)
  if Rails.application.secrets.secret_key_base.blank?
    raise Wor::Authentication::Exceptions::NoKeyProvidedError
  end
  Rails.application.secrets.secret_key_base
end
token_maximum_useful_date() click to toggle source
# File lib/wor/authentication/controller.rb, line 21
def token_maximum_useful_date
  Wor::Authentication.maximum_useful_days.days.from_now.to_i
end
token_renew_id() click to toggle source

Helpers which may be overridden

# File lib/wor/authentication/controller.rb, line 33
def token_renew_id
  Devise.friendly_token(32)
end