module G5AuthenticatableApi::Helpers::Rails
Helpers
for rails API controllers
Public Instance Methods
access_token()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 22 def access_token @access_token ||= token_info.access_token end
authenticate_api_user!()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 10 def authenticate_api_user! raise_auth_error unless token_validator.valid? end
current_api_user()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 18 def current_api_user @current_api_user ||= user_fetcher.current_user end
token_data()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 14 def token_data @token_data ||= token_info.token_data end
warden()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 26 def warden request.env['warden'] end
Private Instance Methods
raise_auth_error()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 56 def raise_auth_error auth_header = token_validator.auth_response_header response.headers['WWW-Authenticate'] = auth_header render json: { error: 'Unauthorized' }, status: :unauthorized end
token_info()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 32 def token_info @token_info ||= Services::TokenInfo.new( request.params, request.headers, warden ) end
token_validator()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 40 def token_validator @token_validator ||= Services::TokenValidator.new( request.params, request.headers, warden ) end
user_fetcher()
click to toggle source
# File lib/g5_authenticatable_api/helpers/rails.rb, line 48 def user_fetcher @user_fetcher ||= Services::UserFetcher.new( request.params, request.headers, warden ) end