diff options
author | Rhenium <rhenium@rhe.jp> | 2014-01-23 06:46:24 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-01-23 06:46:24 +0900 |
commit | 5d05e40f57ae0c7406353d6b888e17e4cb944a62 (patch) | |
tree | 4e4a3d75db004472961cb5c1b0bdbdf4e91713a2 /lib/aclog | |
parent | ced686186bc3f4d2f36d55580fac34a5a9fdc2f7 (diff) | |
download | aclog-5d05e40f57ae0c7406353d6b888e17e4cb944a62.tar.gz |
move TwitterOauthEchoAuthentication to app/controllers/concerns
Diffstat (limited to 'lib/aclog')
-rw-r--r-- | lib/aclog/twitter_oauth_echo_authentication.rb | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/lib/aclog/twitter_oauth_echo_authentication.rb b/lib/aclog/twitter_oauth_echo_authentication.rb deleted file mode 100644 index 1a95bec..0000000 --- a/lib/aclog/twitter_oauth_echo_authentication.rb +++ /dev/null @@ -1,43 +0,0 @@ -require "open-uri" - -module Aclog - module TwitterOauthEchoAuthentication - extend self - - TWITTER_PROVIDER = "https://api.twitter.com/1.1/account/verify_credentials.json" - - module ControllerMethods - extend ActiveSupport::Concern - - module ClassMethods - def twitter_oauth_echo_authenticate_with(provider, options = {}) - before_action(options) do - authenticate_with_twitter_oauth_echo - end - end - end - - def authenticate_with_twitter_oauth_echo - provider = request.headers["X-Auth-Service-Provider"] - credentials = request.headers["X-Verify-Credentials-Authorization"] - unless provider == TWITTER_PROVIDER && credentials - raise Aclog::Exceptions::OAuthEchoUnauthorized - end - - Aclog::TwitterOauthEchoAuthentication.authenticate(provider, credentials) - end - end - - def authenticate(provider, credentials) - res = open(provider, "Authorization" => credentials) - status = res.status[0].to_i - json = JSON.parse(res.read) - res.close - - json["id"] - rescue => e - raise Aclog::Exceptions::OAuthEchoUnauthorized - end - end -end - |