omniauth-dbc 1.0.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.
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
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
data/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # Omniauth Devbootcamp Strategy
2
+ This is the official [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating with auth.devbootcamp.com. To use it you'll need to get a client
3
+ id and secret from [Devbootcamp Auth](https://auth.devbootcamp.com).
4
+
5
+ ## Basic Usage
6
+
7
+ ### Gemfile
8
+ ```ruby
9
+ gem 'omniauth-dbc', :git => 'https://github.com/socrates-api/omniauth-dbc.git'
10
+ ```
11
+
12
+ ### Sessions Controller
13
+ ```ruby
14
+ use OmniAuth::Builder do
15
+ provider :dbc, ENV['AUTH_KEY'], ENV['AUTH_SECRET']
16
+ end
17
+ ```
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new('spec')
5
+
6
+ desc 'Default: run specs.'
7
+ task :default => :spec
8
+
9
+ desc "Run specs"
10
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,2 @@
1
+ require "omniauth-dbc/version"
2
+ require 'omniauth/strategies/dbc'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Dbc
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Dbc < OmniAuth::Strategies::OAuth2
6
+ option :name, :dbc
7
+ option :client_options, {
8
+ :site => 'https://auth.devbootcamp.com',
9
+ :authorize_url => '/oauth/authorize'
10
+ }
11
+
12
+ uid { raw_info["id"] }
13
+
14
+ info do
15
+ {
16
+ :email => raw_info["email"],
17
+ :name => raw_info["name"],
18
+ :id => raw_info["id"],
19
+ :gravatar => raw_info["avatar_image_url"]
20
+ }
21
+ end
22
+
23
+ def raw_info
24
+ @raw_info ||= access_token.get('/me').parsed
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-dbc/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Kevin Buchanan"]
6
+ gem.email = ["kevaustinbuch@gmail.com"]
7
+ gem.description = %q{Official OmniAuth strategy for DevBootcamp Auth.}
8
+ gem.summary = %q{Official OmniAuth strategy for DevBootcamp Auth.}
9
+ gem.homepage = "https://github.com/socrates-api/omniauth-dbc"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-dbc"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::Dbc::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rspec', '~> 2.7'
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'webmock'
23
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Dbc do
4
+ let(:access_token) { double('AccessToken', :options => {}) }
5
+ let(:parsed_response) { double('ParsedResponse') }
6
+ let(:response) { double('Response', :parsed => parsed_response) }
7
+
8
+ subject do
9
+ OmniAuth::Strategies::Dbc.new({})
10
+ end
11
+
12
+ before(:each) do
13
+ subject.stub(:access_token).and_return(access_token)
14
+ end
15
+
16
+ describe "#client" do
17
+ it 'should have correct site' do
18
+ subject.options.client_options.site.should eq("https://auth.devbootcamp.com")
19
+ end
20
+
21
+ it 'should have correct authorize url' do
22
+ subject.options.client_options.authorize_url.should eq('/oauth/authorize')
23
+ end
24
+ end
25
+
26
+ describe "#raw_info" do
27
+ it "should request and parse user data" do
28
+ access_token.should_receive(:get).with('/me').and_return(response)
29
+ subject.raw_info.should eq(parsed_response)
30
+ end
31
+ end
32
+
33
+ describe '#info' do
34
+ before :each do
35
+ @raw_info = {
36
+ 'name' => 'John Smith',
37
+ 'email' => 'me@example.com',
38
+ 'avatar_image_url' => 'source',
39
+ 'id' => 1
40
+ }
41
+ subject.stub(:raw_info) { @raw_info }
42
+ end
43
+
44
+ context 'when data is present in raw info' do
45
+ it 'returns the name' do
46
+ subject.info[:name].should eq('John Smith')
47
+ end
48
+
49
+ it 'returns the email' do
50
+ subject.info[:email].should eq('me@example.com')
51
+ end
52
+
53
+ it 'returns the gravatar source' do
54
+ subject.info[:gravatar].should eq('source')
55
+ end
56
+
57
+ it 'returns the id' do
58
+ subject.info[:id].should eq(1)
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,13 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'webmock/rspec'
4
+ require 'omniauth'
5
+ require 'omniauth-dbc'
6
+ require 'rspec'
7
+ require 'rack/test'
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
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dbc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kevin Buchanan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-22 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
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.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
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.1'
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: webmock
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
+ description: Official OmniAuth strategy for DevBootcamp Auth.
95
+ email:
96
+ - kevaustinbuch@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - README.md
104
+ - Rakefile
105
+ - lib/omniauth-dbc.rb
106
+ - lib/omniauth-dbc/version.rb
107
+ - lib/omniauth/strategies/dbc.rb
108
+ - omniauth-dbc.gemspec
109
+ - spec/dbc/strategies/dbc_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: https://github.com/socrates-api/omniauth-dbc
112
+ licenses: []
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.24
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Official OmniAuth strategy for DevBootcamp Auth.
135
+ test_files:
136
+ - spec/dbc/strategies/dbc_spec.rb
137
+ - spec/spec_helper.rb