omniauth-mlh 0.2.1 → 0.4.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- N2I3YTE0OTE4MGQ4ZWFhOTAzNDRlMzRiMWI1MGZmYTRlMDE5ZGYyYQ==
5
- data.tar.gz: !binary |-
6
- YmMxOWNlY2I1ZGEyZmIyMTNjYTVmMGJkYWZkYjViYjcwNjg5OTU2ZQ==
2
+ SHA256:
3
+ metadata.gz: 1608c1c551536f2dde7aa485c7b6f61ed4ffa9131805d930f12e65aeb09b25ee
4
+ data.tar.gz: fcaf372603aede88fc7623f6aa981aefea2467597907a5266ab4f3ba57f4345b
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NWNjNWI5YzNlNDA4YzNkZjM2MzNlNzRkNTE5NWU5MDYzMGI3ODc2YjQ2MjZk
10
- MzI1ZTAxMjQyMjgzOGM1MjYxNzI4MjUxYjdmNDYyYTQwMWUzNTg5NTNjNTI5
11
- MjExMmE1YzYxMDg5NzRmNDUyMDEyZDgxNWNkNjIyZTAyODFjMzY=
12
- data.tar.gz: !binary |-
13
- YjNmY2NmNGE0ZDFlMzRkZWY5MGU1ZmQxMjNmYTk1ODdlY2NjMGRkMTI4MGZl
14
- YmJjNTAyYjY1YTc5MzU2OTEzNzNlNGY5MTUyNGI5MTI1YjUzNGVjMmI2MWY2
15
- MmIwMzRjYzFiMzNkOThkYzY5ZmIzYzNmZDExODNlMmUyMjQ5Y2U=
6
+ metadata.gz: fffcc909ecd51283296ed328d36c5770a6fd0e1d11e8f51f40d9abb67ba0db4ce2b5638d0e83afdbeec01d39ed1393a9dcac311bc6c99d7ae291d7066313f50d
7
+ data.tar.gz: 8ca616032f69b5e082b02a880a75562d1620594d8fb34c611a05041d2e7217095240a6595aa5cf503b7ed2cf1a06a931ab988c7c91e405b5e64dd29add0eda63
@@ -0,0 +1 @@
1
+ 2.2.4
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.1
3
+ - 2.2.4
data/README.md CHANGED
@@ -1,16 +1,18 @@
1
- # OmniAuth MLH
1
+ # MLH/my-mlh-omniauth
2
2
 
3
- This is the official OmniAuth strategy for authenticating to My MLH. To use
4
- it, you'll need to sign up for an OAuth2 Application ID and Secret on the
5
- [My MLH Applications Page](https://my.mlh.io/oauth/applications).
3
+ [![Build Status](https://travis-ci.org/MLH/my-mlh-omniauth.svg?branch=master)](https://travis-ci.org/MLH/my-mlh-omniauth)
6
4
 
7
- # Usage
5
+ This is the official [OmniAuth](https://github.com/omniauth/omniauth) strategy for
6
+ authenticating with [MyMLH](https://my.mlh.io). To use it, you'll need to
7
+ [register an application](https://my.mlh.io/oauth/applications) and obtain a OAuth Application ID and Secret from MyMLH.
8
8
 
9
- ```
10
- use OmniAuth::Builder do
11
- provider :mlh, ENV['MLH_KEY'], ENV['MLH_SECRET']
12
- end
13
- ```
9
+ It now supports MyMLH API V3. [Read the MyMLH V3 docs here](https://my.mlh.io/docs).
10
+
11
+ Once you have done so, you can follow the instructions below:
12
+
13
+ ## Requirements
14
+
15
+ You need to have at least Ruby 2.2.4 to use this gem.
14
16
 
15
17
  ## Installation
16
18
 
@@ -28,17 +30,39 @@ Or install it yourself as:
28
30
 
29
31
  $ gem install omniauth-mlh
30
32
 
33
+ ## Usage (Rack)
34
+
35
+ ```ruby
36
+ use OmniAuth::Builder do
37
+ provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday'
38
+ end
39
+ ```
40
+
41
+ ## Usage (Rails with Devise)
42
+
43
+ ```ruby
44
+ # config/devise.rb
45
+
46
+ Devise.setup do |config|
47
+ config.provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday'
48
+ end
49
+ ```
50
+
31
51
  ## Contributing
32
52
 
33
- 1. Fork it ( https://github.com/mlh/omniauth-mlh/fork )
53
+ 1. Fork it ( https://github.com/mlh/my-mlh-omniauth/fork )
34
54
  2. Create your feature branch (`git checkout -b my-new-feature`)
35
55
  3. Commit your changes (`git commit -am 'Add some feature'`)
36
56
  4. Push to the branch (`git push origin my-new-feature`)
37
57
  5. Create a new Pull Request
38
58
 
59
+ ## Credit
60
+
61
+ We used part of [datariot/omniauth-paypal](http://github.com/datariot/omniauth-paypal)'s code to help us test this gem.
62
+
39
63
  ## Questions?
40
64
 
41
65
  Have a question about the API or this library? Start by checking out the
42
- [official My MLH documentation](https://my.mlh.io/docs). If you still can't
66
+ [official MyMLH documentation](https://my.mlh.io/docs). If you still can't
43
67
  find an answer, tweet at [@MLHacks](http://twitter.com/mlhacks) or drop an
44
- email to [hi@mlh.io](mailto://hi@mlh.io).
68
+ email to [engineering@mlh.io](mailto:engineering@mlh.io).
@@ -1,2 +1,3 @@
1
+ require "active_support"
1
2
  require "omniauth-mlh/version"
2
3
  require "omniauth/strategies/mlh"
@@ -1,5 +1,9 @@
1
1
  module OmniAuth
2
2
  module MLH
3
- VERSION = "0.2.1"
3
+ MAJOR_VERSION = 0
4
+ MINOR_VERSION = 4
5
+ RELEASE_VERSION = 1
6
+
7
+ VERSION = [MAJOR_VERSION, MINOR_VERSION, RELEASE_VERSION].join('.')
4
8
  end
5
9
  end
@@ -1,4 +1,5 @@
1
1
  require 'omniauth-oauth2'
2
+ require 'ostruct'
2
3
 
3
4
  module OmniAuth
4
5
  module Strategies
@@ -6,37 +7,32 @@ module OmniAuth
6
7
  option :name, :mlh
7
8
 
8
9
  option :client_options, {
9
- :site => 'https://my.mlh.io',
10
- :authorize_url => '/oauth/authorize',
11
- :token_url => '/oauth/token'
10
+ :site => 'https://my.mlh.io',
11
+ :authorize_path => '/oauth/authorize',
12
+ :token_path => '/oauth/token'
12
13
  }
13
14
 
14
- uid { raw_info['data']['id'] }
15
+ uid { data[:id] }
15
16
 
16
17
  info do
17
- {
18
- :email => raw_info['data']['email'],
19
- :created_at => raw_info['data']['created_at'],
20
- :updated_at => raw_info['data']['updated_at'],
21
- :first_name => raw_info['data']['first_name'],
22
- :last_name => raw_info['data']['last_name'],
23
- :graduation => raw_info['data']['graduation'],
24
- :major => raw_info['data']['major'],
25
- :shirt_size => raw_info['data']['shirt_size'],
26
- :dietary_restrictions => raw_info['data']['dietary_restrictions'],
27
- :special_needs => raw_info['data']['special_needs'],
28
- :date_of_birth => raw_info['data']['date_of_birth'],
29
- :gender => raw_info['data']['gender'],
30
- :phone_number => raw_info['data']['phone_number'],
31
- :school => {
32
- :id => raw_info['data']['school']['id'],
33
- :name => raw_info['data']['school']['name'],
34
- }
35
- }
18
+ data.slice(
19
+ :email,
20
+ :created_at,
21
+ :updated_at,
22
+ :first_name,
23
+ :last_name,
24
+ :level_of_study,
25
+ :major,
26
+ :date_of_birth,
27
+ :gender,
28
+ :phone_number,
29
+ :scopes,
30
+ :school
31
+ )
36
32
  end
37
33
 
38
- def raw_info
39
- @raw_info ||= access_token.get('/api/v1/user.json').parsed
34
+ def data
35
+ @data ||= access_token.get('/api/v3/user.json').parsed.deep_symbolize_keys[:data] rescue {}
40
36
  end
41
37
  end
42
38
  end
@@ -14,15 +14,19 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "http://github.com/mlh/omniauth-mlh"
15
15
  spec.license = "MIT"
16
16
 
17
+ spec.required_ruby_version = '>= 2.2.4'
18
+
17
19
  spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
20
  spec.files = `git ls-files`.split("\n")
19
21
  spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
22
  spec.require_paths = ["lib"]
21
23
 
22
24
  spec.add_dependency 'omniauth', '~> 1.0'
23
- spec.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
25
+ spec.add_dependency 'omniauth-oauth2', '~> 1.3.1'
26
+ spec.add_dependency 'activesupport'
24
27
 
25
28
  spec.add_development_dependency 'rspec', '~> 2.7'
29
+ spec.add_development_dependency 'rake', '~> 10.5'
26
30
  spec.add_development_dependency 'rack-test'
27
31
  spec.add_development_dependency 'simplecov'
28
32
  spec.add_development_dependency 'webmock'
@@ -2,16 +2,35 @@ require 'spec_helper'
2
2
 
3
3
  describe OmniAuth::MLH do
4
4
  subject do
5
- OmniAuth::Strategies::MLH.new({})
5
+ OmniAuth::Strategies::MLH.new(nil, @options || {})
6
6
  end
7
7
 
8
- context "client options" do
9
- it 'should have correct site' do
10
- expect(subject.options.client_options.site).to eq('https://my.mlh.io')
8
+ it_should_behave_like 'an oauth2 strategy'
9
+
10
+ describe '#client' do
11
+ it 'has correct MyMLH site' do
12
+ expect(subject.client.site).to eq('https://my.mlh.io')
13
+ end
14
+
15
+ it 'has correct authorize url' do
16
+ expect(subject.client.options[:authorize_url]).to eq('/oauth/authorize')
17
+ end
18
+
19
+ it 'has correct token url' do
20
+ expect(subject.client.options[:token_url]).to eq('/oauth/token')
21
+ end
22
+
23
+ it 'runs the setup block if passed one' do
24
+ counter = ''
25
+ @options = { :setup => Proc.new { |env| counter = 'ok' } }
26
+ subject.setup_phase
27
+ expect(counter).to eq("ok")
11
28
  end
29
+ end
12
30
 
13
- it 'should have correct authorize url' do
14
- expect(subject.options.client_options.authorize_path).to eq('/oauth/authorize')
31
+ describe '#callback_path' do
32
+ it "has the correct callback path" do
33
+ expect(subject.callback_path).to eq('/auth/mlh/callback')
15
34
  end
16
35
  end
17
36
  end
@@ -1,14 +1,20 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
2
3
  require 'simplecov'
3
4
  SimpleCov.start
5
+
6
+ require 'bundler/setup'
4
7
  require 'rspec'
5
8
  require 'rack/test'
6
9
  require 'webmock/rspec'
7
10
  require 'omniauth'
8
11
  require 'omniauth-mlh'
12
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
9
13
 
10
14
  RSpec.configure do |config|
11
15
  config.include WebMock::API
12
16
  config.include Rack::Test::Methods
13
17
  config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
18
+
19
+ OmniAuth.config.test_mode = true
14
20
  end
@@ -0,0 +1,39 @@
1
+ # Credit: https://github.com/datariot/omniauth-paypal/blob/master/spec/support/shared_examples.rb
2
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
3
+
4
+ shared_examples 'an oauth2 strategy' do
5
+ describe '#client' do
6
+ it 'should be initialized with symbolized client_options' do
7
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
8
+ expect(subject.client.options[:authorize_url]).to eq('https://example.com')
9
+ end
10
+ end
11
+
12
+ describe '#authorize_params' do
13
+ it 'should include any authorize params passed in the :authorize_params option' do
14
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
15
+ expect(subject.authorize_params['foo']).to eq('bar')
16
+ expect(subject.authorize_params['baz']).to eq('zip')
17
+ end
18
+
19
+ it 'should include top-level options that are marked as :authorize_options' do
20
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
21
+ expect(subject.authorize_params['scope']).to eq('bar')
22
+ expect(subject.authorize_params['foo']).to eq('baz')
23
+ end
24
+ end
25
+
26
+ describe '#token_params' do
27
+ it 'should include any token params passed in the :token_params option' do
28
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
29
+ expect(subject.token_params['foo']).to eq('bar')
30
+ expect(subject.token_params['baz']).to eq('zip')
31
+ end
32
+
33
+ it 'should include top-level options that are marked as :token_options' do
34
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
35
+ expect(subject.token_params['scope']).to eq('bar')
36
+ expect(subject.token_params['foo']).to eq('baz')
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,103 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-mlh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swift
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2020-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: omniauth-oauth2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.1
34
- - - <
35
- - !ruby/object:Gem::Version
36
- version: '2.0'
33
+ version: 1.3.1
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ! '>='
38
+ - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: 1.1.1
44
- - - <
40
+ version: 1.3.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
45
46
  - !ruby/object:Gem::Version
46
- version: '2.0'
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: rspec
49
57
  requirement: !ruby/object:Gem::Requirement
50
58
  requirements:
51
- - - ~>
59
+ - - "~>"
52
60
  - !ruby/object:Gem::Version
53
61
  version: '2.7'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
65
  requirements:
58
- - - ~>
66
+ - - "~>"
59
67
  - !ruby/object:Gem::Version
60
68
  version: '2.7'
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.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.5'
61
83
  - !ruby/object:Gem::Dependency
62
84
  name: rack-test
63
85
  requirement: !ruby/object:Gem::Requirement
64
86
  requirements:
65
- - - ! '>='
87
+ - - ">="
66
88
  - !ruby/object:Gem::Version
67
89
  version: '0'
68
90
  type: :development
69
91
  prerelease: false
70
92
  version_requirements: !ruby/object:Gem::Requirement
71
93
  requirements:
72
- - - ! '>='
94
+ - - ">="
73
95
  - !ruby/object:Gem::Version
74
96
  version: '0'
75
97
  - !ruby/object:Gem::Dependency
76
98
  name: simplecov
77
99
  requirement: !ruby/object:Gem::Requirement
78
100
  requirements:
79
- - - ! '>='
101
+ - - ">="
80
102
  - !ruby/object:Gem::Version
81
103
  version: '0'
82
104
  type: :development
83
105
  prerelease: false
84
106
  version_requirements: !ruby/object:Gem::Requirement
85
107
  requirements:
86
- - - ! '>='
108
+ - - ">="
87
109
  - !ruby/object:Gem::Version
88
110
  version: '0'
89
111
  - !ruby/object:Gem::Dependency
90
112
  name: webmock
91
113
  requirement: !ruby/object:Gem::Requirement
92
114
  requirements:
93
- - - ! '>='
115
+ - - ">="
94
116
  - !ruby/object:Gem::Version
95
117
  version: '0'
96
118
  type: :development
97
119
  prerelease: false
98
120
  version_requirements: !ruby/object:Gem::Requirement
99
121
  requirements:
100
- - - ! '>='
122
+ - - ">="
101
123
  - !ruby/object:Gem::Version
102
124
  version: '0'
103
125
  description: Official OmniAuth strategy for My MLH.
@@ -107,9 +129,10 @@ executables: []
107
129
  extensions: []
108
130
  extra_rdoc_files: []
109
131
  files:
110
- - .gitignore
111
- - .rspec
112
- - .travis.yml
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".ruby-version"
135
+ - ".travis.yml"
113
136
  - Gemfile
114
137
  - LICENSE.txt
115
138
  - README.md
@@ -120,30 +143,31 @@ files:
120
143
  - omniauth-mlh.gemspec
121
144
  - spec/omniauth/mlh_spec.rb
122
145
  - spec/spec_helper.rb
146
+ - spec/support/shared_examples.rb
123
147
  homepage: http://github.com/mlh/omniauth-mlh
124
148
  licenses:
125
149
  - MIT
126
150
  metadata: {}
127
- post_install_message:
151
+ post_install_message:
128
152
  rdoc_options: []
129
153
  require_paths:
130
154
  - lib
131
155
  required_ruby_version: !ruby/object:Gem::Requirement
132
156
  requirements:
133
- - - ! '>='
157
+ - - ">="
134
158
  - !ruby/object:Gem::Version
135
- version: '0'
159
+ version: 2.2.4
136
160
  required_rubygems_version: !ruby/object:Gem::Requirement
137
161
  requirements:
138
- - - ! '>='
162
+ - - ">="
139
163
  - !ruby/object:Gem::Version
140
164
  version: '0'
141
165
  requirements: []
142
- rubyforge_project:
143
- rubygems_version: 2.2.2
144
- signing_key:
166
+ rubygems_version: 3.0.8
167
+ signing_key:
145
168
  specification_version: 4
146
169
  summary: Official OmniAuth strategy for My MLH.
147
170
  test_files:
148
171
  - spec/omniauth/mlh_spec.rb
149
172
  - spec/spec_helper.rb
173
+ - spec/support/shared_examples.rb