omniauth-gaggleamp 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a82ae38eac102846938e013040f61940516e7db6
4
+ data.tar.gz: da95259eff1c79a9abd90e7e2cbe01737e8e7958
5
+ SHA512:
6
+ metadata.gz: 86e0e73655c76cd4e7fd880a6182c84c2ff043d5ce8900c4990c5eb195b68198f9d8a39b9ba70c4aa3ebd6f2eebbac36e46af5f90a63ee3d936bfa2c760da762
7
+ data.tar.gz: 2d45f778eeb6dc37a85c70f3c14f1f9ed80c8a887e0c5e330af5fa1dd0eb889df692b93bed4b236966cfebb99b1b763ded0b15a3048f67454677d646043e0cc0
data/.gitignore ADDED
@@ -0,0 +1,18 @@
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
18
+ .env
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-gaggleamp.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'gemfury_helpers'
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 GaggleAMP
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,31 @@
1
+ # OmniAuth GaggleAMP OAuth2 Strategy
2
+
3
+ A GaggleAMP OAuth2 strategy for OmniAuth.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'omniauth-gaggleamp'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install omniauth-gaggleamp
18
+
19
+ ## Usage
20
+
21
+ Register your application with GaggleAMP to receive an API key.
22
+
23
+ This is an example that you might put into a Rails initializer at `config/initializers/omniauth.rb`:
24
+
25
+ ```ruby
26
+ Rails.application.config.middleware.use OmniAuth::Builder do
27
+ provider :gaggleamp, ENV['GAGGLEAMP_KEY'], ENV['GAGGLEAMP_SECRET']
28
+ end
29
+ ```
30
+
31
+ You can now access the OmniAuth GaggleAMP OAuth2 URL: `/auth/gaggleamp`.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require 'gemfury_helpers'
2
+ require 'rspec/core/rake_task'
3
+
4
+ GemfuryHelpers::GemHelper.install_tasks
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
data/example/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'omniauth-gaggleamp', :path => '..'
data/example/config.ru ADDED
@@ -0,0 +1,31 @@
1
+ # Sample app for GaggleAMP Strategy
2
+ # Make sure to setup the ENV variables GAGGLEAMP_KEY and GAGGLEAMP_SECRET
3
+ # Run with "bundle exec rackup"
4
+
5
+ require 'bundler/setup'
6
+ require 'sinatra/base'
7
+ require 'omniauth-gaggleamp'
8
+
9
+ class App < Sinatra::Base
10
+ get '/' do
11
+ redirect '/auth/gaggleamp'
12
+ end
13
+
14
+ get '/auth/:provider/callback' do
15
+ content_type 'application/json'
16
+ MultiJson.encode(request.env['omniauth.auth'])
17
+ end
18
+
19
+ get '/auth/failure' do
20
+ content_type 'application/json'
21
+ MultiJson.encode(request.env)
22
+ end
23
+ end
24
+
25
+ use Rack::Session::Cookie, :secret => 'change_me'
26
+
27
+ use OmniAuth::Builder do
28
+ provider :gaggleamp, ENV['GAGGLEAMP_KEY'], ENV['GAGGLEAMP_SECRET']
29
+ end
30
+
31
+ run App.new
@@ -0,0 +1,2 @@
1
+ require 'omniauth-gaggleamp/version'
2
+ require 'omniauth/strategies/gaggleamp'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module GaggleAMP
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,49 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ # Authentication strategy for connecting with GaggleAMP using
6
+ # the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10).
7
+ # You must generally register your application with GaggleAMP and
8
+ # utilize a client id and secret in order to authenticate using
9
+ # OAuth 2.0.
10
+ class GaggleAMP < OmniAuth::Strategies::OAuth2
11
+ # This is where you pass the options you would pass when
12
+ # initializing your consumer from the OAuth gem.
13
+ option :client_options, {
14
+ :site => 'https://accounts.gaggleamp.com'
15
+ }
16
+
17
+ uid { raw_info['id'] }
18
+
19
+ info do
20
+ {
21
+ :name => raw_info['name'],
22
+ :email => raw_info['email'],
23
+ :nickname => raw_info['nickname']
24
+ }
25
+ end
26
+
27
+ extra do
28
+ { 'raw_info' => raw_info }
29
+ end
30
+
31
+ def raw_info
32
+ @raw_info ||= access_token.get('/user').parsed
33
+ end
34
+
35
+ # Override authorization parameters to support user provider preference.
36
+ def authorize_params
37
+ super.tap do |params|
38
+ provider = session['omniauth.params'].delete('provider') rescue nil
39
+ params[:provider] = provider if provider
40
+
41
+ service = session['omniauth.params'].delete('service') rescue nil
42
+ params[:service] = service if service
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ OmniAuth.config.add_camelization 'gaggleamp', 'GaggleAMP'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-gaggleamp/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-gaggleamp"
8
+ spec.version = OmniAuth::GaggleAMP::VERSION
9
+ spec.authors = ["GaggleAMP"]
10
+ spec.email = ["info@gaggleamp.com"]
11
+ spec.description = %q{A GaggleAMP OAuth2 strategy for OmniAuth.}
12
+ spec.summary = %q{A GaggleAMP OAuth2 strategy for OmniAuth.}
13
+ spec.homepage = "https://github.com/GaggleAMP/omniauth-gaggleamp"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency "omniauth", "~> 1.0"
21
+ spec.add_runtime_dependency "omniauth-oauth2"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", "~> 2.13.0"
26
+ spec.add_development_dependency "simplecov"
27
+ end
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-gaggleamp'
3
+
4
+ describe OmniAuth::Strategies::GaggleAMP do
5
+ subject { OmniAuth::Strategies::GaggleAMP.new(nil) }
6
+
7
+ it 'should add a camelization for itself' do
8
+ OmniAuth::Utils.camelize('gaggleamp').should == 'GaggleAMP'
9
+ end
10
+
11
+ describe '#client' do
12
+ it 'has correct GaggleAMP site' do
13
+ subject.client.site.should eq('https://accounts.gaggleamp.com')
14
+ end
15
+
16
+ it 'has correct authorize url' do
17
+ subject.client.options[:authorize_url].should eq('/oauth/authorize')
18
+ end
19
+
20
+ it 'has correct token url' do
21
+ subject.client.options[:token_url].should eq('/oauth/token')
22
+ end
23
+ end
24
+
25
+ describe '#callback_path' do
26
+ it 'has the correct callback path' do
27
+ subject.callback_path.should eq('/auth/gaggleamp/callback')
28
+ end
29
+ end
30
+
31
+ describe '#uid' do
32
+ before :each do
33
+ subject.stub(:raw_info) { { 'id' => 'uid' } }
34
+ end
35
+
36
+ it 'returns the id from raw_info' do
37
+ subject.uid.should eq('uid')
38
+ end
39
+ end
40
+
41
+ describe '#info' do
42
+ before :each do
43
+ subject.stub(:raw_info) { {} }
44
+ end
45
+
46
+ context 'and therefore has all the necessary fields' do
47
+ it { subject.info.should have_key :name }
48
+ it { subject.info.should have_key :email }
49
+ it { subject.info.should have_key :nickname }
50
+ end
51
+ end
52
+
53
+ describe '#extra' do
54
+ before :each do
55
+ subject.stub(:raw_info) { { :foo => 'bar' } }
56
+ end
57
+
58
+ it { subject.extra['raw_info'].should eq({ :foo => 'bar' }) }
59
+ end
60
+
61
+ describe '#raw_info' do
62
+ before :each do
63
+ response = double('response', :parsed => { :foo => 'bar' })
64
+ subject.stub(:access_token) { double('access token', :get => response) }
65
+ end
66
+
67
+ it 'returns parsed response from access token' do
68
+ subject.raw_info.should eq({ :foo => 'bar' })
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,20 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ # This file was generated by the `rspec --init` command. Conventionally, all
5
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
+ # Require this file using `require "spec_helper"` to ensure that it is only
7
+ # loaded once.
8
+ #
9
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
10
+ RSpec.configure do |config|
11
+ config.treat_symbols_as_metadata_keys_with_true_values = true
12
+ config.run_all_when_everything_filtered = true
13
+ config.filter_run :focus
14
+
15
+ # Run specs in random order to surface order dependencies. If you find an
16
+ # order dependency and want to debug it, you can fix the order by providing
17
+ # the seed, which is printed after each run.
18
+ # --seed 1234
19
+ config.order = 'random'
20
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-gaggleamp
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - GaggleAMP
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 2.13.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 2.13.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A GaggleAMP OAuth2 strategy for OmniAuth.
98
+ email:
99
+ - info@gaggleamp.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .gitignore
105
+ - .rspec
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - example/Gemfile
111
+ - example/config.ru
112
+ - lib/omniauth-gaggleamp.rb
113
+ - lib/omniauth-gaggleamp/version.rb
114
+ - lib/omniauth/strategies/gaggleamp.rb
115
+ - omniauth-gaggleamp.gemspec
116
+ - spec/omniauth/strategies/gaggleamp_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/GaggleAMP/omniauth-gaggleamp
119
+ licenses: []
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.2.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: A GaggleAMP OAuth2 strategy for OmniAuth.
141
+ test_files:
142
+ - spec/omniauth/strategies/gaggleamp_spec.rb
143
+ - spec/spec_helper.rb
144
+ has_rdoc: