module G5AuthenticatableApi::Helpers::Grape
Helper methods for securing a Grape
API
Public Instance Methods
access_token()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 22 def access_token @access_token ||= token_info.access_token end
authenticate_user!()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 10 def authenticate_user! raise_auth_error unless token_validator.valid? end
current_user()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 18 def current_user @current_user ||= user_fetcher.current_user end
request()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 30 def request Rack::Request.new(env) end
token_data()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 14 def token_data @token_data ||= token_info.token_data end
warden()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 26 def warden env['warden'] end
Protected Instance Methods
raise_auth_error()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 52 def raise_auth_error auth_header = { 'WWW-Authenticate' => token_validator.auth_response_header } throw :error, message: 'Unauthorized', status: 401, headers: auth_header end
token_info()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 36 def token_info @token_info ||= Services::TokenInfo.new(request.params, headers, warden) end
token_validator()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 40 def token_validator @token_validator ||= Services::TokenValidator.new(request.params, headers, warden) end
user_fetcher()
click to toggle source
# File lib/g5_authenticatable_api/helpers/grape.rb, line 46 def user_fetcher @user_fetcher ||= Services::UserFetcher.new(request.params, headers, warden) end