omniauth-clio 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - ree
6
+ - jruby
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-clio.gemspec
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # OmniAuth clio
2
+
3
+ This gem contains the clio strategy for OmniAuth. I used the omniauth-twitter gem as a template to getting this up and running. Yay open source!!
4
+
5
+ clio uses the OAuth 2.0 flow, you can read about it here: http://api-docs.goclio.com/v1/index.html#authorization-with-oauth-2-0
6
+
7
+ ## How To Use It
8
+
9
+ Usage is as per any other OmniAuth 2.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
10
+
11
+ gem 'omniauth-clio'
12
+
13
+ You can pull them in directly from github e.g.:
14
+
15
+ gem 'omniauth-clio', :git => 'https://github.com/shicholas/omniauth-clio.git'
16
+
17
+ Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
18
+
19
+ Rails.application.config.middleware.use OmniAuth::Builder do
20
+ provider :clio, "consumer_key", "consumer_secret"
21
+ end
22
+
23
+ You will obviously have to put in your key and secret, which you get when you register your app with clio (they call them API Key and Secret Key).
24
+
25
+
26
+ ## Watch the RailsCast
27
+
28
+ Ryan Bates has put together an excellent RailsCast on OmniAuth:
29
+
30
+ [![RailsCast #241](https://www.evernote.com/shard/s35/sh/479f2503-aefa-4542-a7b4-8f84fd22eafc/0571f5a3795a0be3d0b0814312a8d5b7/res/49b5478a-657c-4aff-ae58-dae08b9a46d5/Screen_Shot_2012-07-15_at_12.41.15_PM-20120715-125424.jpg.jpg "RailsCast #241 - Simple OmniAuth (revised)")](http://railscasts.com/episodes/241-simple-omniauth-revised)
31
+
32
+
33
+ ## Supported Rubies
34
+
35
+ OmniAuth clio is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
36
+
37
+ [![CI Build
38
+ Status](https://secure.travis-ci.org/arunagw/omniauth-clio.png)](http://travis-ci.org/arunagw/omniauth-clio)
39
+
40
+ ## Note on Patches/Pull Requests
41
+
42
+ - Fork the project.
43
+ - Make your feature addition or bug fix.
44
+ - Add tests for it. This is important so I don’t break it in a future version unintentionally.
45
+ - Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
46
+ - Send me a pull request. Bonus points for topic branches.
47
+
48
+ ## License
49
+
50
+ Copyright (c) 2011 by Nicholas Shook
51
+
52
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
53
+
54
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
55
+
56
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-clio/version"
2
+ require 'omniauth/strategies/clio'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Clio
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,68 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class clio < OmniAuth::Strategies::OAuth
7
+ option :name, 'clio'
8
+ option :client_options, {:authorize_path => '/oauth/authenticate',
9
+ :site => 'http://api-docs.goclio.com/',
10
+ :proxy => ENV['http_proxy'] ? URI(ENV['http_proxy']) : nil}
11
+
12
+ uid { access_token.params[:user_id] }
13
+
14
+ info do
15
+ {
16
+ :nickname => raw_info['screen_name'],
17
+ :name => raw_info['name'],
18
+ :location => raw_info['location'],
19
+ :image => raw_info['profile_image_url'],
20
+ :description => raw_info['description'],
21
+ :urls => {
22
+ 'Website' => raw_info['url'],
23
+ 'clio' => 'http://goclio.com/' + raw_info['screen_name'],
24
+ }
25
+ }
26
+ end
27
+
28
+ extra do
29
+ { :raw_info => raw_info }
30
+ end
31
+
32
+ def raw_info
33
+ @raw_info ||= MultiJson.load(access_token.get('/1/account/verify_credentials.json').body)
34
+ rescue ::Errno::ETIMEDOUT
35
+ raise ::Timeout::Error
36
+ end
37
+
38
+ alias :old_request_phase :request_phase
39
+
40
+ def request_phase
41
+ force_login = session['omniauth.params'] ? session['omniauth.params']['force_login'] : nil
42
+ screen_name = session['omniauth.params'] ? session['omniauth.params']['screen_name'] : nil
43
+ x_auth_access_type = session['omniauth.params'] ? session['omniauth.params']['x_auth_access_type'] : nil
44
+ if force_login && !force_login.empty?
45
+ options[:authorize_params] ||= {}
46
+ options[:authorize_params].merge!(:force_login => 'true')
47
+ end
48
+ if screen_name && !screen_name.empty?
49
+ options[:authorize_params] ||= {}
50
+ options[:authorize_params].merge!(:force_login => 'true', :screen_name => screen_name)
51
+ end
52
+ if x_auth_access_type
53
+ options[:request_params] || {}
54
+ options[:request_params].merge!(:x_auth_access_type => x_auth_access_type)
55
+ end
56
+
57
+ if session['omniauth.params'] && session['omniauth.params']["use_authorize"] == "true"
58
+ options.client_options.authorize_path = '/oauth/authorize'
59
+ else
60
+ options.client_options.authorize_path = '/oauth/authenticate'
61
+ end
62
+
63
+ old_request_phase
64
+ end
65
+
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-clio/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-clio"
7
+ s.version = OmniAuth::Clio::VERSION
8
+ s.authors = ["Nick Shook"]
9
+ s.email = ["nicholas.shook@gmail.com"]
10
+ s.homepage = "https://github.com/shicholas/omniauth-clio"
11
+ s.summary = %q{OmniAuth strategy for Clio}
12
+ s.description = %q{OmniAuth strategy for Clio}
13
+
14
+ s.rubyforge_project = "omniauth-clio"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'multi_json', '~> 1.3'
22
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::clio do
4
+ subject do
5
+ OmniAuth::Strategies::clio.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct name' do
10
+ subject.options.name.should eq("clio")
11
+ end
12
+
13
+ it 'should have correct site' do
14
+ subject.options.client_options.site.should eq('http://api-docs.goclio.com')
15
+ end
16
+
17
+ it 'should have correct authorize url' do
18
+ subject.options.client_options.authorize_path.should eq('/oauth/authenticate')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-clio'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-clio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nick Shook
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: multi_json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: OmniAuth strategy for Clio
111
+ email:
112
+ - nicholas.shook@gmail.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - .rspec
119
+ - .travis.yml
120
+ - Gemfile
121
+ - README.md
122
+ - Rakefile
123
+ - lib/omniauth-clio.rb
124
+ - lib/omniauth-clio/version.rb
125
+ - lib/omniauth/strategies/Clio.rb
126
+ - omniauth-clio.gemspec
127
+ - spec/omniauth/strategies/clio_spec.rb
128
+ - spec/spec_helper.rb
129
+ homepage: https://github.com/shicholas/omniauth-clio
130
+ licenses: []
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project: omniauth-clio
149
+ rubygems_version: 1.8.24
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: OmniAuth strategy for Clio
153
+ test_files:
154
+ - spec/omniauth/strategies/clio_spec.rb
155
+ - spec/spec_helper.rb