Skip to content

Instantly share code, notes, and snippets.

@zeeshangulzar
Last active November 18, 2020 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeeshangulzar/64c682c2065043f8700aa3e21d3aa1dc to your computer and use it in GitHub Desktop.
Save zeeshangulzar/64c682c2065043f8700aa3e21d3aa1dc to your computer and use it in GitHub Desktop.
api_authentication_controller.rb
require 'authentication/token_authentication'
class ApiAuthenticationController < ApplicationController
before_filter :authenticate_request
private
def authenticate_request
if request && request.headers && request.headers['Authorization']
token = request.headers['Authorization']
@auth_client = TokenAuthentication.authenticate_token(token)
return if @auth_client.present?
end
head :unauthorized
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment