Sha256: 798a9c0d2774cab0c7efb56098de5bd34a4346c9a58f304fcb92da5ff399a669
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
require 'g5_authenticatable_api/services/token_validator' require 'g5_authenticatable_api/services/user_fetcher' module G5AuthenticatableApi module Helpers module Grape def authenticate_user! raise_auth_error if !token_validator.valid? end def token_data @token_data ||= token_info.token_data end def current_user @current_user ||= user_fetcher.current_user end def access_token @access_token ||= token_info.access_token end def warden env['warden'] end private def request Rack::Request.new(env) end def token_info @token_info ||= Services::TokenInfo.new(request.params, headers, warden) end def token_validator @token_validator ||= Services::TokenValidator.new(request.params, headers, warden) end def user_fetcher @user_fetcher ||= Services::UserFetcher.new(request.params, headers, warden) end def raise_auth_error throw :error, message: 'Unauthorized', status: 401, headers: {'WWW-Authenticate' => token_validator.auth_response_header} end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
g5_authenticatable_api-0.4.1 | lib/g5_authenticatable_api/helpers/grape.rb |
g5_authenticatable_api-0.4.0 | lib/g5_authenticatable_api/helpers/grape.rb |