omniauth-connexio 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 32b7cb485143203265edb943acdbbe97f26b079e
4
+ data.tar.gz: a925780ef935afbeb234ba232e8a8aa07ead4d60
5
+ SHA512:
6
+ metadata.gz: 931e54662765712f3e9adf8ec35074cacf5ce7cce1d320c1d1bbad4e5080e46fac7f7d9cfd850013e03a68e0d51c34a73d88c2ecc9f049d651a6c3858a7a98e7
7
+ data.tar.gz: 1b007234f88bca0f31689ea09564bbc5686ed1bdc73aa00e70d9f6110d43fe9e012cb00da879a9b462751938bb51935957f01185334fe877f7eb64bd300711d5
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=progress
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - jruby
8
+ addons:
9
+ code_climate:
10
+ # repo_token: acf391ea515caa468e74c55532dddebed1e1d32b235bee0845e04700e8c634aa
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-connexio.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 John Allen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # OmniAuth Connexio
2
+
3
+ This is an OmniAuth strategy for authenticating to Connexio. To use it, you'll need to create an OAuth Client Application on Connexio's [Applications Page](login.connexiolabs.com/clients/new).
4
+
5
+ TODO: Write a gem description
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-connexio'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-connexio
20
+
21
+ ## Usage
22
+
23
+ In a Rails app, add the Tumblr provider to your Omniauth middleware, e.g. in a file like @config/initializers/omniauth.rb@:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :connexio, ENV['CONNEXIO_KEY'], ENV['CONNEXIO_SECRET']
28
+ end
29
+ ```
30
+
31
+ In any Rack app you can add the Tumblr strategy like so:
32
+
33
+ ```ruby
34
+ use OmniAuth::Builder do
35
+ provider :connexio, ENV['CONNEXIO_KEY'], ENV['CONNEXIO_SECRET']
36
+ end
37
+ ```
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( http://github.com/<my-github-username>/omniauth-connexio/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :test, :development
4
+
5
+ Bundler::GemHelper.install_tasks
6
+
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task default: [:spec]
13
+
14
+ task :console do
15
+ require 'pry'
16
+ require 'grape-slate'
17
+ ARGV.clear
18
+ Pry.start
19
+ end
@@ -0,0 +1,2 @@
1
+ require 'omniauth-connexio/version'
2
+ require 'omniauth/strategies/connexio'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Connexio
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Connexio < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ site: 'https://login.connexiolabs.com',
8
+ token_url: '/oauth/access_token'
9
+ }
10
+
11
+ uid { raw_info['id'] }
12
+
13
+ info do
14
+ {
15
+ name: "#{raw_info['first_name']} #{raw_info['last_name']}",
16
+ email: raw_info['email_address'],
17
+ first_name: raw_info['first_name'],
18
+ last_name: raw_info['last_name'],
19
+ phone: raw_info['phone_number']
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { raw_info: raw_info }
25
+ end
26
+
27
+ def raw_info
28
+ access_token.options[:mode] = :query
29
+
30
+ @raw_info ||= access_token.get('/oauth/user').parsed
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-connexio/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'omniauth-connexio'
8
+ spec.version = OmniAuth::Connexio::VERSION
9
+ spec.authors = ['John Allen']
10
+ spec.email = ['john@threedogconsulting.com']
11
+ spec.summary = %q{OmniAuth strategy for Connexio}
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/connexio-labs/omniauth-connexio'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'omniauth-oauth2', '~> 1.1'
22
+
23
+ spec.add_development_dependency 'coveralls', '~> 0.7'
24
+ spec.add_development_dependency 'rspec', '~> 2.14'
25
+ spec.add_development_dependency 'bundler', '~> 1.5'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Connexio do
4
+ subject { OmniAuth::Strategies::Connexio.new(nil) }
5
+
6
+ describe '#client' do
7
+ it 'has correct Connexio site' do
8
+ expect(subject.client.site).to eq('https://login.connexiolabs.com')
9
+ end
10
+
11
+ it 'has correct authorize url' do
12
+ expect(subject.client.options[:authorize_url]).to eq('/oauth/authorize')
13
+ end
14
+
15
+ it 'has correct token url' do
16
+ expect(subject.client.options[:token_url]).to eq('/oauth/access_token')
17
+ end
18
+ end
19
+
20
+ describe '#callback_path' do
21
+ it 'has the correct callback path' do
22
+ expect(subject.callback_path).to eq('/auth/connexio/callback')
23
+ end
24
+ end
25
+
26
+ describe '#uid' do
27
+ before :each do
28
+ allow(subject).to receive(:raw_info) { { 'id' => 'uid' } }
29
+ end
30
+
31
+ it 'returns the id from raw_info' do
32
+ expect(subject.uid).to eq('uid')
33
+ end
34
+ end
35
+
36
+ describe '#info' do
37
+ context 'and therefore has all the necessary fields' do
38
+ before :each do
39
+ allow(subject).to receive(:raw_info) {
40
+ {
41
+ 'first_name' => 'John',
42
+ 'last_name' => 'Smith',
43
+ 'email_address' => 'john.smith@example.com',
44
+ 'phone_number' => '5555551212'
45
+ }
46
+ }
47
+ end
48
+
49
+ it { expect(subject.info).to have_key :name }
50
+ it { expect(subject.info).to have_key :email }
51
+ it { expect(subject.info).to have_key :first_name }
52
+ it { expect(subject.info).to have_key :last_name }
53
+ it { expect(subject.info).to have_key :phone }
54
+ end
55
+
56
+ context 'and does not fail with empty response' do
57
+ before :each do
58
+ allow(subject).to receive(:raw_info) { {} }
59
+ end
60
+
61
+ it { expect { subject.info }.not_to raise_error }
62
+ end
63
+ end
64
+
65
+ describe '#extra' do
66
+ before :each do
67
+ allow(subject).to receive(:raw_info) { { 'foo' => 'bar' } }
68
+ end
69
+
70
+ it { expect(subject.extra[:raw_info]).to eq({ 'foo' => 'bar' }) }
71
+ end
72
+
73
+ describe '#raw_info' do
74
+ before :each do
75
+ response = double(:response, parsed: { 'foo' => 'bar' })
76
+
77
+ allow(subject).to receive(:access_token) do
78
+ double('access token', get: response, options: {})
79
+ end
80
+ end
81
+
82
+ it 'returns parsed response from access token' do
83
+ expect(subject.raw_info).to eq({ 'foo' => 'bar' })
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,13 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'omniauth-connexio'
5
+
6
+ require 'rubygems'
7
+ require 'bundler'
8
+ Bundler.setup :default, :test
9
+
10
+ require 'coveralls'
11
+ Coveralls.wear!
12
+
13
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-connexio
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - John Allen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth-oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.14'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: OmniAuth strategy for Connexio
84
+ email:
85
+ - john@threedogconsulting.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - lib/omniauth-connexio.rb
98
+ - lib/omniauth-connexio/version.rb
99
+ - lib/omniauth/strategies/connexio.rb
100
+ - omniauth-connexio.gemspec
101
+ - spec/omniauth/strategies/connexio_spec.rb
102
+ - spec/spec_helper.rb
103
+ homepage: https://github.com/connexio-labs/omniauth-connexio
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.2.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: OmniAuth strategy for Connexio
127
+ test_files:
128
+ - spec/omniauth/strategies/connexio_spec.rb
129
+ - spec/spec_helper.rb
130
+ has_rdoc: