omniauth-songwriter 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b25f7580c521a3bfeed0a2a190871c4902ae69a7
4
+ data.tar.gz: 322447c16f1caf253e188679a90c65857b58dda3
5
+ SHA512:
6
+ metadata.gz: f3513445c8a2a1f598731ec61911acdc552a41c2c714799cf3b6d56478adc5cb7c66bde3590df2aeffbd3edb7d156779e27f5d183b8f1bf42de6a8b1d634a422
7
+ data.tar.gz: ede59ab551ed8bef4fb2dc18d66d2b145a1a3ddc4a9f9528de257881a484be6d38dda9e75ecae222c09fcd15ca50f34ea6ae98ae770d7a606a7d973571fc10e6
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ # Specify your gem's dependencies in omniauth-eindx.gemspec
5
+ group :test do
6
+ gem 'rack-test'
7
+ gem 'rake'
8
+ gem 'rspec'
9
+ gem 'webmock'
10
+ end
11
+
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-songwriter (0.1.0)
5
+ hashr
6
+ omniauth-oauth2
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.3.5)
12
+ crack (0.4.1)
13
+ safe_yaml (~> 0.9.0)
14
+ diff-lcs (1.2.4)
15
+ faraday (0.9.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ hashie (2.0.5)
18
+ hashr (0.0.22)
19
+ jwt (0.1.11)
20
+ multi_json (>= 1.5)
21
+ multi_json (1.9.2)
22
+ multi_xml (0.5.5)
23
+ multipart-post (2.0.0)
24
+ oauth2 (0.9.3)
25
+ faraday (>= 0.8, < 0.10)
26
+ jwt (~> 0.1.8)
27
+ multi_json (~> 1.3)
28
+ multi_xml (~> 0.5)
29
+ rack (~> 1.2)
30
+ omniauth (1.2.1)
31
+ hashie (>= 1.2, < 3)
32
+ rack (~> 1.0)
33
+ omniauth-oauth2 (1.1.2)
34
+ faraday (>= 0.8, < 0.10)
35
+ multi_json (~> 1.3)
36
+ oauth2 (~> 0.9.3)
37
+ omniauth (~> 1.2)
38
+ rack (1.5.2)
39
+ rack-test (0.6.2)
40
+ rack (>= 1.0)
41
+ rake (10.1.0)
42
+ rspec (2.14.1)
43
+ rspec-core (~> 2.14.0)
44
+ rspec-expectations (~> 2.14.0)
45
+ rspec-mocks (~> 2.14.0)
46
+ rspec-core (2.14.5)
47
+ rspec-expectations (2.14.2)
48
+ diff-lcs (>= 1.1.3, < 2.0)
49
+ rspec-mocks (2.14.3)
50
+ safe_yaml (0.9.5)
51
+ webmock (1.13.0)
52
+ addressable (>= 2.2.7)
53
+ crack (>= 0.3.2)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ bundler (~> 1.3)
60
+ omniauth-songwriter!
61
+ rack-test
62
+ rake
63
+ rspec
64
+ webmock
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Felix Clack
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.
@@ -0,0 +1,21 @@
1
+ # Omniauth::Songwriter
2
+
3
+ An OmniAuth strategy for connecting to the Songwriter.io ID service.
4
+
5
+ Add this to `config/initializers/devise.rb`
6
+
7
+ Devise.setup do |config|
8
+ ...
9
+ config.omniauth :songwriter, APP_ID, APP_SECRET
10
+ end
11
+
12
+ To change the endpoint of the provider, make use of the `setup` option
13
+ available to `Rack::Builder`.
14
+
15
+ Devise.setup do |config|
16
+ config.omniauth :songwriter, APP_ID, APP_SECRET,
17
+ setup: lambda { |env|
18
+ env['omniauth.strategy'].options[:client_options].site = "https://id.provider.com"
19
+ }
20
+ end
21
+
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run all specs in spec directory"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: [:spec]
8
+
@@ -0,0 +1,2 @@
1
+ require 'omniauth/strategies/songwriter'
2
+
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Songwriter
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Songwriter < OmniAuth::Strategies::OAuth2
6
+ option :name, 'songwriter'
7
+ option :client_options, { site: 'https://id.songwriter.io' }
8
+
9
+ uid { raw_info['uid'].to_s }
10
+
11
+ info do
12
+ raw_info
13
+ end
14
+
15
+ def raw_info
16
+ @raw_info ||= access_token.get('/me').parsed
17
+ end
18
+ end
19
+ end
20
+ end
21
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth/songwriter/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-songwriter"
8
+ spec.version = OmniAuth::Songwriter::VERSION
9
+ spec.authors = ["Felix Clack"]
10
+ spec.email = ["felixclack@gmail.com"]
11
+ spec.description = %q{Provide access to the OAuth2 provider powering SSO for all things Songwriter}
12
+ spec.summary = %q{An OmniAuth strategy for Songwriter.io}
13
+ spec.homepage = "https://github.com/eindx/omniauth-songwriter"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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"
22
+ spec.add_dependency "hashr"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Songwriter do
4
+ def app; lambda{|env| [200, {}, ["Hello."]]} end
5
+ let(:fresh_strategy){ Class.new(OmniAuth::Strategies::Songwriter) }
6
+
7
+ before do
8
+ OmniAuth.config.test_mode = true
9
+ end
10
+
11
+ after do
12
+ OmniAuth.config.test_mode = false
13
+ end
14
+
15
+ describe '#client' do
16
+ subject{ fresh_strategy }
17
+
18
+ it 'should be initialized with symbolized client_options' do
19
+ instance = subject.new(app, :client_options => {'authorize_url' => 'https://example.com'})
20
+ instance.client.options[:authorize_url].should == 'https://example.com'
21
+ end
22
+
23
+ it 'should set ssl options as connection options' do
24
+ instance = subject.new(app, :client_options => {'ssl' => {'ca_path' => 'foo'}})
25
+ instance.client.options[:connection_opts][:ssl] =~ {:ca_path => 'foo'}
26
+ end
27
+ end
28
+
29
+ describe '#authorize_params' do
30
+ subject { fresh_strategy }
31
+
32
+ it 'should include any authorize params passed in the :authorize_params option' do
33
+ instance = subject.new('abc', 'def', :authorize_params => {:foo => 'bar', :baz => 'zip'})
34
+ instance.authorize_params['foo'].should == 'bar'
35
+ instance.authorize_params['baz'].should == 'zip'
36
+ end
37
+
38
+ it 'should include top-level options that are marked as :authorize_options' do
39
+ instance = subject.new('abc', 'def', :authorize_options => [:scope, :foo, :state], :scope => 'bar', :foo => 'baz')
40
+ instance.authorize_params['scope'].should == 'bar'
41
+ instance.authorize_params['foo'].should == 'baz'
42
+ end
43
+
44
+ it 'should include random state in the authorize params' do
45
+ instance = subject.new('abc', 'def')
46
+ instance.authorize_params.keys.should == ['state']
47
+ instance.session['omniauth.state'].should_not be_empty
48
+ end
49
+ end
50
+
51
+ describe '#token_params' do
52
+ subject { fresh_strategy }
53
+
54
+ it 'should include any authorize params passed in the :authorize_params option' do
55
+ instance = subject.new('abc', 'def', :token_params => {:foo => 'bar', :baz => 'zip'})
56
+ instance.token_params.should == {'foo' => 'bar', 'baz' => 'zip'}
57
+ end
58
+
59
+ it 'should include top-level options that are marked as :authorize_options' do
60
+ instance = subject.new('abc', 'def', :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz')
61
+ instance.token_params.should == {'scope' => 'bar', 'foo' => 'baz'}
62
+ end
63
+ end
64
+ end
65
+
@@ -0,0 +1,14 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'rspec'
4
+ require 'rack/test'
5
+ require 'webmock/rspec'
6
+ require 'omniauth'
7
+ require 'omniauth-songwriter'
8
+
9
+ RSpec.configure do |config|
10
+ config.include WebMock::API
11
+ config.include Rack::Test::Methods
12
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
13
+ end
14
+
@@ -0,0 +1,15 @@
1
+ box: wercker/ubuntu12.04-ruby2.0.0
2
+ services:
3
+ - wercker/postgresql
4
+
5
+ build:
6
+ steps:
7
+ - bundle-install
8
+ - rails-database-yml
9
+ - script:
10
+ name: Setup DB
11
+ code: bundle exec rake db:setup
12
+
13
+ - script:
14
+ name: rake
15
+ code: bundle exec rake
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-songwriter
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Felix Clack
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-28 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hashr
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
+ description: Provide access to the OAuth2 provider powering SSO for all things Songwriter
56
+ email:
57
+ - felixclack@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - lib/omniauth-songwriter.rb
69
+ - lib/omniauth/songwriter/version.rb
70
+ - lib/omniauth/strategies/songwriter.rb
71
+ - omniauth-songwriter.gemspec
72
+ - spec/omniauth/strategies/songwriter_spec.rb
73
+ - spec/spec_helper.rb
74
+ - wercker.yml
75
+ homepage: https://github.com/eindx/omniauth-songwriter
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.2.0
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: An OmniAuth strategy for Songwriter.io
99
+ test_files:
100
+ - spec/omniauth/strategies/songwriter_spec.rb
101
+ - spec/spec_helper.rb