class Remotty::Rails::Authentication::Strategies::TokenHeaderAuthenticable
Public Instance Methods
authenticate!()
click to toggle source
email에 해당하는 token을 auth_token 테이블에서 확인
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 27 def authenticate! resource_scope = mapping.to resource = resource_scope.find_by_email(header_email) if resource if ENV["RAILS_ENV"] == "development"# && header_token.nil? success!(resource) else auth_token = resource.auth_tokens.where("token = ? and updated_at > ?", Digest::SHA512.hexdigest(header_token), mapping.to.remember_for.ago).first if auth_token auth_token.update_source source, source_info success!(resource) else fail! end end else fail! end end
store?()
click to toggle source
use session?
Calls superclass method
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 17 def store? super && !mapping.to.skip_session_storage.include?(:token_header_auth) end
valid?()
click to toggle source
개발일 경우는 email만 있어도 통과! 아니면 email + token header 필요
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 22 def valid? header_email && (ENV["RAILS_ENV"] == "development" || header_token) end
Private Instance Methods
header_email()
click to toggle source
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 60 def header_email request.headers["X-Auth-Email"] || request.params["X-Auth-Email"] end
header_token()
click to toggle source
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 64 def header_token request.headers["X-Auth-Token"] || request.params["X-Auth-Token"] end
source()
click to toggle source
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 52 def source request.headers["X-Auth-Device"] || 'web' end
source_info()
click to toggle source
# File lib/remotty/rails/authentication/strategies/token_header_authenticable.rb, line 56 def source_info request.headers["X-Auth-Device-Info"] || request.remote_ip end