omniauth-mlh 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/README.md +33 -13
- data/lib/omniauth/strategies/mlh.rb +23 -25
- data/lib/omniauth-mlh/version.rb +5 -1
- data/lib/omniauth-mlh.rb +1 -0
- data/omniauth-mlh.gemspec +4 -0
- data/spec/omniauth/mlh_spec.rb +25 -6
- data/spec/spec_helper.rb +6 -0
- data/spec/support/shared_examples.rb +39 -0
- metadata +52 -22
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MmIwODYzYWFkYzVjMmY2OTdlZjliMmYyMzQxMzE1MmI3YTM2ODUzNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03307dc90020f08280faac875faec0ac71111031
|
4
|
+
data.tar.gz: e1829e9813ca6b21319006f5de592877e87ba7ea
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZDcwODExMWY4MTU5OGZkYjhmNTVhMTFhNzYzYjhiODExODk4ZmQxM2NlZWEw
|
11
|
-
NjNhMmYzMmY4OTJmNjAyZmMwOWZhMTZjN2M1MWI1NDdhMGFmMTI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
MTQ4NmM5ODdiN2FjN2FiNzJlNGExMGFmZWY4Njc2NWVhYTQzYjBhZDFjYjlm
|
14
|
-
MTA0M2ZhY2E5YmViOWQ0MTg3YTJkYjg4NDQwMzAwNzNmYzJmYjlkOTA1OWI0
|
15
|
-
Y2YxNTMxNDJjZGU0Y2M0MjY1ZjhkOTdkODYwMDcxNTMwOTFiMmQ=
|
6
|
+
metadata.gz: 2135d947f6b2c3f1982157648d2deb43a36fccfb28dbec1b8d9878e1070934f8faf63414bf3be376aa3a3ac9f33c7003b9a60cc2e17256be8308ef82a68ee1d4
|
7
|
+
data.tar.gz: 7da3955342e679c494f88f3237a509c536aebba722568c39b0095f16e2fec1be513bb62593c820bdc86fb85fc266e70ac27636c6af7860face5e9799559652e8
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.4
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# MLH/my-mlh-omniauth
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
```
|
9
|
+
It now supports [MyMLH API V2](http://news.mlh.io/introducing-mymlh-v2-09-29-2016). [Read the MyMLH V2 docs here](https://my.mlh.io/docs).
|
10
|
+
|
11
|
+
Once you have done so, you can follow the instructions below:
|
14
12
|
|
15
13
|
## Installation
|
16
14
|
|
@@ -28,17 +26,39 @@ Or install it yourself as:
|
|
28
26
|
|
29
27
|
$ gem install omniauth-mlh
|
30
28
|
|
29
|
+
## Usage (Rack)
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
use OmniAuth::Builder do
|
33
|
+
provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday'
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Usage (Rails with Devise)
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# config/devise.rb
|
41
|
+
|
42
|
+
Devise.setup do |config|
|
43
|
+
config.provider :mlh, ENV['MY_MLH_KEY'], ENV['MY_MLH_SECRET'], scope: 'default email birthday'
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
31
47
|
## Contributing
|
32
48
|
|
33
|
-
1. Fork it ( https://github.com/mlh/
|
49
|
+
1. Fork it ( https://github.com/mlh/my-mlh-omniauth/fork )
|
34
50
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
51
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
52
|
4. Push to the branch (`git push origin my-new-feature`)
|
37
53
|
5. Create a new Pull Request
|
38
54
|
|
55
|
+
## Credit
|
56
|
+
|
57
|
+
We used part of [datariot/omniauth-paypal](http://github.com/datariot/omniauth-paypal)'s code to help us test this gem.
|
58
|
+
|
39
59
|
## Questions?
|
40
60
|
|
41
61
|
Have a question about the API or this library? Start by checking out the
|
42
|
-
[official
|
62
|
+
[official MyMLH documentation](https://my.mlh.io/docs). If you still can't
|
43
63
|
find an answer, tweet at [@MLHacks](http://twitter.com/mlhacks) or drop an
|
44
|
-
email to [
|
64
|
+
email to [engineering@mlh.io](mailto:engineering@mlh.io).
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'omniauth-oauth2'
|
2
|
+
require 'ostruct'
|
2
3
|
|
3
4
|
module OmniAuth
|
4
5
|
module Strategies
|
@@ -6,38 +7,35 @@ module OmniAuth
|
|
6
7
|
option :name, :mlh
|
7
8
|
|
8
9
|
option :client_options, {
|
9
|
-
:site
|
10
|
+
:site => 'https://my.mlh.io',
|
10
11
|
:authorize_path => '/oauth/authorize',
|
11
|
-
:token_path
|
12
|
+
:token_path => '/oauth/token'
|
12
13
|
}
|
13
14
|
|
14
|
-
uid {
|
15
|
+
uid { data[:id] }
|
15
16
|
|
16
17
|
info do
|
17
|
-
|
18
|
-
:email
|
19
|
-
:created_at
|
20
|
-
:updated_at
|
21
|
-
:first_name
|
22
|
-
:last_name
|
23
|
-
:level_of_study
|
24
|
-
:major
|
25
|
-
:shirt_size
|
26
|
-
:dietary_restrictions
|
27
|
-
:special_needs
|
28
|
-
:date_of_birth
|
29
|
-
:gender
|
30
|
-
:phone_number
|
31
|
-
:scopes
|
32
|
-
:school
|
33
|
-
|
34
|
-
:name => raw_info['data']['school']['name'],
|
35
|
-
}
|
36
|
-
}
|
18
|
+
data.slice(
|
19
|
+
:email,
|
20
|
+
:created_at,
|
21
|
+
:updated_at,
|
22
|
+
:first_name,
|
23
|
+
:last_name,
|
24
|
+
:level_of_study,
|
25
|
+
:major,
|
26
|
+
:shirt_size,
|
27
|
+
:dietary_restrictions,
|
28
|
+
:special_needs,
|
29
|
+
:date_of_birth,
|
30
|
+
:gender,
|
31
|
+
:phone_number,
|
32
|
+
:scopes,
|
33
|
+
:school
|
34
|
+
)
|
37
35
|
end
|
38
36
|
|
39
|
-
def
|
40
|
-
@
|
37
|
+
def data
|
38
|
+
@data ||= access_token.get('/api/v2/user.json').parsed.deep_symbolize_keys[:data] rescue {}
|
41
39
|
end
|
42
40
|
end
|
43
41
|
end
|
data/lib/omniauth-mlh/version.rb
CHANGED
data/lib/omniauth-mlh.rb
CHANGED
data/omniauth-mlh.gemspec
CHANGED
@@ -14,6 +14,8 @@ 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")
|
@@ -21,8 +23,10 @@ Gem::Specification.new do |spec|
|
|
21
23
|
|
22
24
|
spec.add_dependency 'omniauth', '~> 1.0'
|
23
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'
|
data/spec/omniauth/mlh_spec.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
14
|
-
|
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
|
data/spec/spec_helper.rb
CHANGED
@@ -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,97 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-mlh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swift
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 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
33
|
version: 1.3.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 1.3.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
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'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - ~>
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '2.7'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - ~>
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
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'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: rack-test
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
58
86
|
requirements:
|
59
|
-
- -
|
87
|
+
- - ">="
|
60
88
|
- !ruby/object:Gem::Version
|
61
89
|
version: '0'
|
62
90
|
type: :development
|
63
91
|
prerelease: false
|
64
92
|
version_requirements: !ruby/object:Gem::Requirement
|
65
93
|
requirements:
|
66
|
-
- -
|
94
|
+
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: simplecov
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
|
-
- -
|
101
|
+
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
103
|
version: '0'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- -
|
108
|
+
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: webmock
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
|
-
- -
|
115
|
+
- - ">="
|
88
116
|
- !ruby/object:Gem::Version
|
89
117
|
version: '0'
|
90
118
|
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
|
-
- -
|
122
|
+
- - ">="
|
95
123
|
- !ruby/object:Gem::Version
|
96
124
|
version: '0'
|
97
125
|
description: Official OmniAuth strategy for My MLH.
|
@@ -101,9 +129,10 @@ executables: []
|
|
101
129
|
extensions: []
|
102
130
|
extra_rdoc_files: []
|
103
131
|
files:
|
104
|
-
- .gitignore
|
105
|
-
- .rspec
|
106
|
-
- .
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".ruby-version"
|
135
|
+
- ".travis.yml"
|
107
136
|
- Gemfile
|
108
137
|
- LICENSE.txt
|
109
138
|
- README.md
|
@@ -114,6 +143,7 @@ files:
|
|
114
143
|
- omniauth-mlh.gemspec
|
115
144
|
- spec/omniauth/mlh_spec.rb
|
116
145
|
- spec/spec_helper.rb
|
146
|
+
- spec/support/shared_examples.rb
|
117
147
|
homepage: http://github.com/mlh/omniauth-mlh
|
118
148
|
licenses:
|
119
149
|
- MIT
|
@@ -124,21 +154,21 @@ require_paths:
|
|
124
154
|
- lib
|
125
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
126
156
|
requirements:
|
127
|
-
- -
|
157
|
+
- - ">="
|
128
158
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
159
|
+
version: 2.2.4
|
130
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
161
|
requirements:
|
132
|
-
- -
|
162
|
+
- - ">="
|
133
163
|
- !ruby/object:Gem::Version
|
134
164
|
version: '0'
|
135
165
|
requirements: []
|
136
166
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.4.5.1
|
138
168
|
signing_key:
|
139
169
|
specification_version: 4
|
140
170
|
summary: Official OmniAuth strategy for My MLH.
|
141
171
|
test_files:
|
142
172
|
- spec/omniauth/mlh_spec.rb
|
143
173
|
- spec/spec_helper.rb
|
144
|
-
|
174
|
+
- spec/support/shared_examples.rb
|