omniauth-unipass 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -15,18 +15,3 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
-
19
- yardoc/
20
- .rvmrc
21
-
22
- # System/IDE files
23
- Desktop.ini
24
- Thumbs.db
25
- nbproject
26
- .DS_Store
27
- .idea
28
- .redcar
29
- \#*#
30
- *.swp
31
- *.swo
32
- *~
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-unipass.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Connectmedica.com
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 CHANGED
@@ -1,28 +1,128 @@
1
- # OmniAuth GitHub
1
+ # OmniAuth Unipass  [![Build Status](https://secure.travis-ci.org/connectmedica/omniauth-unipass.png)][travis] [![Dependency Status](https://gemnasium.com/connectmedica/omniauth-unipass.png?travis)][gemnasium]
2
2
 
3
- This is the official OmniAuth strategy for authenticating to Unipass.
3
+ Unipass OAuth2 Strategy for [OmniAuth 1.0](https://github.com/intridea/omniauth) authentication system.
4
4
 
5
- ## Basic Usage
5
+ Supports the OAuth 2.0 server-side flow.
6
6
 
7
- use OmniAuth::Builder do
8
- provider :unipas, ENV['CLIENT_ID'], ENV['CLIENT_SECRET']
9
- end
7
+ [travis]: http://travis-ci.org/connectmedica/omniauth-unipass
8
+ [gemnasium]: https://gemnasium.com/connectmedica/omniauth-unipass
10
9
 
11
- ## Advanced Usage
10
+ ## Installation
12
11
 
13
- use OmniAuth::Builder do
14
- provider :unipas, ENV['CLIENT_ID'], ENV['CLIENT_SECRET'],
15
- :site => ENV['SITE'],
16
- :api_site => ENV['API_SITE'],
17
- :setup => true
18
- end
12
+ Add this line to your application's Gemfile:
19
13
 
20
- ## License
14
+ gem 'omniauth-unipass'
21
15
 
22
- Copyright (c) 2011 Connectmedica.com.
16
+ And then execute:
23
17
 
24
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
18
+ $ bundle
25
19
 
26
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+ Or install it yourself as:
27
21
 
28
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ $ gem install omniauth-unipass
23
+
24
+ ## Usage
25
+
26
+ Set up the strategy as a middleware in Ruby on Rails (eg. in `config/initializers/omniauth.rb`):
27
+
28
+ ```ruby
29
+ Rails.application.config.middleware.use OmniAuth::Builder do
30
+ provider :unipass, ENV['UNIPASS_CLIENT_ID'], ENV['UNIPASS_CLIENT_SECRET']
31
+ end
32
+ ```
33
+
34
+ ...or if you are using [Devise-Omniauthable](https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview) (inside your `config/initializers/devise.rb`):
35
+
36
+ ```ruby
37
+ config.omniauth :unipass, ENV['UNIPASS_CLIENT_ID'], ENV['UNIPASS_CLIENT_SECRET']
38
+ ```
39
+
40
+ ## Configuration
41
+
42
+ You can set application-wide `scope` and `display` options:
43
+
44
+ ```ruby
45
+ Rails.application.config.middleware.use OmniAuth::Builder do
46
+ provider :unipass, ENV['UNIPASS_CLIENT_ID'], ENV['UNIPASS_CLIENT_SECRET'],
47
+ :display => 'popup',
48
+ :scope => 'email'
49
+ end
50
+ ```
51
+
52
+ ...or you can simply pass the `display` parameter for single request:
53
+
54
+ ```ruby
55
+ link_to('Unipass Login', '/auth/unipass?display=mobile')
56
+ ```
57
+
58
+ ...or using Devise-Omniauthable helper:
59
+
60
+ ```ruby
61
+ user_omniauth_authorize_path(:unipass, :display => :mobile)
62
+ ```
63
+
64
+ Valid options for `display` parameter are:
65
+
66
+ * `popup` for streamlined fluid-width layout appropriate for popup windows.
67
+ * `mobile` for minimal, low-bandwidth layout appropriate for mobile devices.
68
+ * ...or leave it blank for standard full-screen layout.
69
+
70
+ ## Client options
71
+
72
+ If you are testing your application using local (or test) Unipass server, you can customize the path using `client_options`:
73
+
74
+ ```ruby
75
+ Rails.application.config.middleware.use OmniAuth::Builder do
76
+ provider :unipass, ENV['UNIPASS_CLIENT_ID'], ENV['UNIPASS_CLIENT_SECRET'],
77
+ :client_options => {
78
+ :site => 'https://test.stworzonedlazdrowia.pl', # Change it to your local Unipass server
79
+ :api_site => 'https://test.stworzonedlazdrowia.pl/api/1' # Change it to your local Unipass API server
80
+ }
81
+ ```
82
+
83
+ ## Auth Hash
84
+
85
+ Example of *Auth Hash* available via `request.env['omniauth.auth']`:
86
+
87
+ ```ruby
88
+ {
89
+ :provider => 'unipass',
90
+ :id => 'ab123cd456ef',
91
+ :info => {
92
+ :name => 'Stefan Tabory',
93
+ :first_name => 'Stefan',
94
+ :last_name => 'Tabory',
95
+ :location => 'mazowieckie'
96
+ },
97
+ :credentials => {
98
+ :token => 'x_34D-Hd...', # OAuth 2.0 access_token, which you can store in session for later use in API client
99
+ :refresh_token => 'zGNMuLR-...', # OAuth 2.0 refresh_token, used to generate new access_tokens
100
+ :expires_at => 1321747205, # when the access token expires (if it expires)
101
+ :expires => true # if you request `offline_access` this will be false
102
+ },
103
+ :extra => {
104
+ :raw_info => {
105
+ :date_of_birth => '1978-11-24',
106
+ :first_name => 'Stefan',
107
+ :last_name => 'Tabory',
108
+ :province => 'mazowieckie',
109
+ :sex => false,
110
+ :name => 'Stefan Tabory',
111
+ :id => 'ab123cd456ef',
112
+ :admin => true
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ## Contributing
119
+
120
+ 1. Fork it
121
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
122
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
123
+ 4. Push to the branch (`git push origin my-new-feature`)
124
+ 5. Create new Pull Request
125
+
126
+ ## Credits
127
+
128
+ A big credits go to the authors of [mkdynamic/omniauth-facebook](https://github.com/mkdynamic/omniauth-facebook), on which this strategy is based.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -1,2 +1 @@
1
- require "omniauth-unipass/version"
2
- require 'omniauth/strategies/unipass'
1
+ require 'omniauth/unipass'
@@ -1,48 +1,64 @@
1
- require 'omniauth/oauth'
2
- require 'multi_json'
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'base64'
3
+ require 'openssl'
3
4
 
4
5
  module OmniAuth
5
6
  module Strategies
6
7
  class Unipass < OmniAuth::Strategies::OAuth2
8
+ DEFAULT_SCOPE = 'email'
7
9
 
8
- def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
9
- options = options.dup
10
- name = options.delete(:name) || 'unipass'
11
- @site = options.delete(:site) || 'http://test.stworzonedlazdrowia.pl/'
12
- @api_site = options.delete(:api_site) || 'http://test.stworzonedlazdrowia.pl/api/1'
13
-
14
- client_options = {
15
- :site => @site,
10
+ option :client_options, {
11
+ :site => 'https://www.stworzonedlazdrowia.pl',
12
+ :api_site => 'https://www.stworzonedlazdrowia.pl/api/1',
16
13
  :authorize_url => '/oauth2/authorize',
17
14
  :token_url => '/oauth2/token'
18
- }.merge(options[:client_options] || {})
15
+ }
19
16
 
20
- super(app, name, client_id, client_secret, client_options, options, &block)
21
- end
17
+ option :access_token_options, {
18
+ :param_name => 'oauth_token'
19
+ }
20
+
21
+ option :authorize_options, [:scope, :display]
22
22
 
23
- protected
23
+ uid { raw_info['id'] }
24
24
 
25
- def auth_hash
26
- OmniAuth::Utils.deep_merge(super, {
27
- 'uid' => user_data['id'],
28
- 'user_info' => user_info,
29
- 'extra' => {'user_hash' => user_data}
30
- })
25
+ info do
26
+ {
27
+ 'name' => raw_info['name'],
28
+ 'first_name' => raw_info['first_name'],
29
+ 'last_name' => raw_info['last_name'],
30
+ 'location' => raw_info['province']
31
+ }
31
32
  end
32
33
 
33
- def user_info
34
+ extra do
34
35
  {
35
- 'first_name' => user_data['first_name'],
36
- 'last_name' => user_data['last_name']
36
+ 'raw_info' => raw_info
37
37
  }
38
38
  end
39
39
 
40
- def user_data
41
- session[:access_token] = @access_token.token
42
- session[:access_token_expires_at] = @access_token.expires_at
43
- session[:refresh_token] = @access_token.refresh_token
40
+ def raw_info
41
+ @raw_info ||= access_token.get("#{options[:client_options][:api_site]}/me").parsed
42
+ end
43
+
44
+ def callback_url
45
+ if options.authorize_options.respond_to?(:callback_url)
46
+ options.authorize_options.callback_url
47
+ else
48
+ super
49
+ end
50
+ end
51
+
52
+ def authorize_params
53
+ super.tap do |params|
54
+ params.merge!(:display => request.params['display']) if request.params['display']
55
+ params.merge!(:state => request.params['state']) if request.params['state']
56
+ params[:scope] ||= DEFAULT_SCOPE
57
+ end
58
+ end
44
59
 
45
- @data ||= MultiJson.decode(@access_token.get("#{@api_site}/me").response.env[:body])
60
+ def access_token_options
61
+ options.access_token_options.inject({}){ |h,(k,v)| h[k.to_sym] = v; h }
46
62
  end
47
63
 
48
64
  end
@@ -0,0 +1,2 @@
1
+ require 'omniauth/unipass/version'
2
+ require 'omniauth/strategies/unipass'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Unipass
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -1,19 +1,23 @@
1
- require File.expand_path('../lib/omniauth-unipass/version', __FILE__)
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/unipass/version', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |gem|
4
5
  gem.authors = ['Aleksadner Dąbrowski', 'Karol Sarnacki']
5
- gem.email = ['aleksander.dabrowski@connectmedica.com', 'karol.sarnacki@connectmedica.pl']
6
- gem.description = 'OmniAuth strategy for Unipass'
7
- gem.summary = 'OmniAuth strategy for Unipass'
8
- gem.homepage = 'https://github.com/tjeden/omniauth-unipass'
6
+ gem.email = ['aleksander.dabrowski@connectmedica.com', 'sodercober@gmail.com']
7
+ gem.description = %q{Unipass strategy for OmniAuth 1.0}
8
+ gem.summary = %q{Unipass strategy for OmniAuth 1.0}
9
+ gem.homepage = 'https://github.com/connectmedica/omniauth-unipass'
9
10
 
10
11
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
12
  gem.files = `git ls-files`.split("\n")
12
13
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
14
  gem.name = 'omniauth-unipass'
14
15
  gem.require_paths = ['lib']
15
- gem.version = OmniAuth::Unipass::VERSION
16
+ gem.version = Omniauth::Unipass::VERSION
16
17
 
17
- gem.add_dependency 'omniauth', '~> 0.3.2'
18
- gem.add_dependency 'multi_json'
18
+ gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
19
+
20
+ gem.add_development_dependency 'rspec', '~> 2.7.0'
21
+ gem.add_development_dependency 'rake'
22
+ gem.add_development_dependency 'simplecov'
19
23
  end
@@ -0,0 +1,220 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+ require 'omniauth-unipass'
5
+ require 'openssl'
6
+ require 'base64'
7
+
8
+ describe OmniAuth::Strategies::Unipass do
9
+ before :each do
10
+ @request = double('Request')
11
+ @request.stub(:params){ {} }
12
+ @request.stub(:cookies){ {} }
13
+
14
+ @client_id = '33ade5204037012f84783c075443e018'
15
+ @client_secret = '47380fc04037012f84783c075443e018'
16
+ end
17
+
18
+ subject do
19
+ args = [@client_id, @client_secret, @options].compact
20
+ OmniAuth::Strategies::Unipass.new(nil, *args).tap do |strategy|
21
+ strategy.stub(:request){ @request }
22
+ end
23
+ end
24
+
25
+ it_should_behave_like 'an oauth2 strategy'
26
+
27
+ describe '#client' do
28
+ it 'has correct Unipass site' do
29
+ subject.client.site.should eq('https://www.stworzonedlazdrowia.pl')
30
+ end
31
+
32
+ it 'has correct Unipass API site' do
33
+ subject.client.options[:api_site].should eq('https://www.stworzonedlazdrowia.pl/api/1')
34
+ end
35
+
36
+ it 'has correct authorize url' do
37
+ subject.client.options[:authorize_url].should eq('/oauth2/authorize')
38
+ end
39
+
40
+ it 'has correct token url' do
41
+ subject.client.options[:token_url].should eq('/oauth2/token')
42
+ end
43
+ end
44
+
45
+ describe '#callback_url' do
46
+ it "returns value from #authorize_options" do
47
+ url = 'http://myapp.example.com/users/oauth2/callbacks/uni'
48
+ @options = {:authorize_options => {:callback_url => url}}
49
+ subject.callback_url.should eq(url)
50
+ end
51
+
52
+ it "callback_url from request" do
53
+ url_base = 'http://myapp.example.com'
54
+ @request.stub(:url){ "#{url_base}/page/path" }
55
+ subject.stub(:script_name){ '' } # to not depend from Rack env
56
+ subject.callback_url.should eq("#{url_base}/auth/unipass/callback")
57
+ end
58
+ end
59
+
60
+ describe '#authorize_params' do
61
+ it 'includes default scope for email access' do
62
+ subject.authorize_params.should be_a(Hash)
63
+ subject.authorize_params[:scope].should eq('email')
64
+ end
65
+
66
+ it 'includes display parameter from request when present' do
67
+ @request.stub(:params){ {'display' => 'mobile'} }
68
+ subject.authorize_params.should be_a(Hash)
69
+ subject.authorize_params[:display].should eq('mobile')
70
+ end
71
+
72
+ it 'includes state parameter from request when present' do
73
+ @request.stub(:params){ {'state' => 'my_state'} }
74
+ subject.authorize_params.should be_a(Hash)
75
+ subject.authorize_params[:state].should eq('my_state')
76
+ end
77
+ end
78
+
79
+ describe '#access_token_options' do
80
+ it 'has correct param name by default' do
81
+ subject.access_token_options[:param_name].should eq('oauth_token')
82
+ end
83
+ end
84
+
85
+ describe '#uid' do
86
+ before :each do
87
+ subject.stub(:raw_info){ {'id' => 'unipass-randomrandom'} }
88
+ end
89
+
90
+ it 'returns the id from raw_info' do
91
+ subject.uid.should eq('unipass-randomrandom')
92
+ end
93
+ end
94
+
95
+ describe '#info' do
96
+ before :each do
97
+ @raw_info ||= {'first_name' => 'Bob', 'province' => 'świętokrzyskie'}
98
+ subject.stub(:raw_info){ @raw_info }
99
+ end
100
+
101
+ context 'when data is not present in raw info' do
102
+ it 'has nil last_name key' do
103
+ subject.info.should have_key('last_name')
104
+ subject.info['last_name'].should be_nil
105
+ end
106
+ end
107
+
108
+ context 'when data is present in raw info' do
109
+ it 'returns the first_name' do
110
+ subject.info['first_name'].should eq('Bob')
111
+ end
112
+
113
+ it 'returns the name' do
114
+ @raw_info['name'] = 'Bob Gedlof'
115
+ subject.info['name'].should eq('Bob Gedlof')
116
+ end
117
+
118
+ it 'returns the last_name' do
119
+ @raw_info['last_name'] = 'Gedlof'
120
+ subject.info['last_name'].should eq('Gedlof')
121
+ end
122
+
123
+ it 'returns the location' do
124
+ subject.info['location'].should eq('świętokrzyskie')
125
+ end
126
+ end
127
+ end
128
+
129
+ describe '#raw_info' do
130
+ before :each do
131
+ @access_token = double('OAuth2::AccessToken')
132
+ subject.stub(:access_token){ @access_token }
133
+ end
134
+
135
+ it 'performs a GET to https://www.stworzonedlazdrowia.pl/api/1/me' do
136
+ @access_token.stub(:get){ double('OAuth2::Response').as_null_object }
137
+ @access_token.should_receive(:get).with('https://www.stworzonedlazdrowia.pl/api/1/me')
138
+ subject.raw_info
139
+ end
140
+
141
+ it 'returns a Hash' do
142
+ @access_token.stub(:get).with('https://www.stworzonedlazdrowia.pl/api/1/me') do
143
+ raw_response = double('Faraday::Response')
144
+ raw_response.stub(:body){ '{ "spam": "ham" }' }
145
+ raw_response.stub(:status){ 200 }
146
+ raw_response.stub(:headers){ {'Content-Type' => 'application/json'} }
147
+ OAuth2::Response.new(raw_response)
148
+ end
149
+ subject.raw_info.should be_a(Hash)
150
+ subject.raw_info['spam'].should eq('ham')
151
+ end
152
+ end
153
+
154
+ describe '#extra' do
155
+ before :each do
156
+ @raw_info = {'name' => 'Bob Gedlof'}
157
+ subject.stub(:raw_info){ @raw_info }
158
+ end
159
+
160
+ it 'returns a Hash' do
161
+ subject.extra.should be_a(Hash)
162
+ end
163
+
164
+ it 'contains raw info' do
165
+ subject.extra.should eq({'raw_info' => @raw_info})
166
+ end
167
+ end
168
+
169
+ describe '#credentials' do
170
+ before :each do
171
+ @access_token = double('OAuth2::AccessToken')
172
+ @access_token.stub(:token)
173
+ @access_token.stub(:expires?)
174
+ @access_token.stub(:expires_at)
175
+ @access_token.stub(:refresh_token)
176
+ subject.stub(:access_token){ @access_token }
177
+ end
178
+
179
+ it 'returns a Hash' do
180
+ subject.credentials.should be_a(Hash)
181
+ end
182
+
183
+ it 'returns the token' do
184
+ @access_token.stub(:token){ 'UpU312ZrZIx2-WSt0tyB4YIcObGnhphN-eHSasQOWU6-Le6wj3hbR8bECiJIs_TbdaKiuqWMeFCpXTEo801DwReIvGRR9WVHH0n4yrAdjIkAhZoLI3n_4LgZeGCzhaGM' }
185
+ subject.credentials['token'].should eq('UpU312ZrZIx2-WSt0tyB4YIcObGnhphN-eHSasQOWU6-Le6wj3hbR8bECiJIs_TbdaKiuqWMeFCpXTEo801DwReIvGRR9WVHH0n4yrAdjIkAhZoLI3n_4LgZeGCzhaGM')
186
+ end
187
+
188
+ it 'returns the expiry status' do
189
+ @access_token.stub(:expires?){ true }
190
+ subject.credentials['expires'].should eq(true)
191
+
192
+ @access_token.stub(:expires?){ false }
193
+ subject.credentials['expires'].should eq(false)
194
+ end
195
+
196
+ it 'returns the refresh token and expiry time when expiring' do
197
+ ten_mins_from_now = (Time.now + 10 * 60).to_i
198
+ @access_token.stub(:expires?){ true }
199
+ @access_token.stub(:refresh_token){ 'yM9_7ltgVGTzxbF67sSjgJQz4r1ejE3nkOU63fXJ1ZFw_cst3z4XeEkovXRIAXvr4AmDhk36j1GYhVDbQ4KY4IoDNuix6y3eQGy57eBJaD3wpdplL12l8Q6srGtCD12P' }
200
+ @access_token.stub(:expires_at){ ten_mins_from_now }
201
+ subject.credentials['refresh_token'].should eq('yM9_7ltgVGTzxbF67sSjgJQz4r1ejE3nkOU63fXJ1ZFw_cst3z4XeEkovXRIAXvr4AmDhk36j1GYhVDbQ4KY4IoDNuix6y3eQGy57eBJaD3wpdplL12l8Q6srGtCD12P')
202
+ subject.credentials['expires_at'].should eq(ten_mins_from_now)
203
+ end
204
+
205
+ it 'does not return the refresh token when it is nil and expiring' do
206
+ @access_token.stub(:expires?){ true }
207
+ @access_token.stub(:refresh_token){ nil }
208
+ subject.credentials['refresh_token'].should be_nil
209
+ subject.credentials.should_not have_key('refresh_token')
210
+ end
211
+
212
+ it 'does not return the refresh token when not expiring' do
213
+ @access_token.stub(:expires?){ false }
214
+ @access_token.stub(:refresh_token){ 'zM9_7ltgVGTzxbF67sSjgJQz4r1ejE3nkOU63fXJ1ZFw_cst3z4XeEkovXRIAXvr4AmDhk36j1GYhVDbQ4KY4IoDNuix6y3eQGy57eBJaD3wpdplL12l8Q6srGtCD12P' }
215
+ subject.credentials['refresh_token'].should be_nil
216
+ subject.credentials.should_not have_key('refresh_token')
217
+ end
218
+ end
219
+
220
+ end
@@ -0,0 +1,10 @@
1
+ require 'bundler/setup'
2
+
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+
6
+ require 'rspec'
7
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
8
+
9
+ RSpec.configure do |config|
10
+ end
@@ -0,0 +1,37 @@
1
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
2
+ shared_examples 'an oauth2 strategy' do
3
+ describe '#client' do
4
+ it 'should be initialized with symbolized client_options' do
5
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
6
+ subject.client.options[:authorize_url].should == 'https://example.com'
7
+ end
8
+ end
9
+
10
+ describe '#authorize_params' do
11
+ it 'should include any authorize params passed in the :authorize_params option' do
12
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
13
+ subject.authorize_params['foo'].should eq('bar')
14
+ subject.authorize_params['baz'].should eq('zip')
15
+ end
16
+
17
+ it 'should include top-level options that are marked as :authorize_options' do
18
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
19
+ subject.authorize_params['scope'].should eq('bar')
20
+ subject.authorize_params['foo'].should eq('baz')
21
+ end
22
+ end
23
+
24
+ describe '#token_params' do
25
+ it 'should include any authorize params passed in the :authorize_params option' do
26
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
27
+ subject.token_params['foo'].should eq('bar')
28
+ subject.token_params['baz'].should eq('zip')
29
+ end
30
+
31
+ it 'should include top-level options that are marked as :authorize_options' do
32
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
33
+ subject.token_params['scope'].should eq('bar')
34
+ subject.token_params['foo'].should eq('baz')
35
+ end
36
+ end
37
+ end
metadata CHANGED
@@ -1,103 +1,114 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: omniauth-unipass
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
13
- - "Aleksadner D\xC4\x85browski"
7
+ authors:
8
+ - Aleksadner Dąbrowski
14
9
  - Karol Sarnacki
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2011-11-04 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: omniauth
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
13
+ date: 2012-02-23 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth-oauth2
17
+ requirement: &70319452389120 !ruby/object:Gem::Requirement
25
18
  none: false
26
- requirements:
19
+ requirements:
27
20
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 23
30
- segments:
31
- - 0
32
- - 3
33
- - 2
34
- version: 0.3.2
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.0
35
23
  type: :runtime
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: multi_json
39
24
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70319452389120
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &70319452388620 !ruby/object:Gem::Requirement
41
29
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
49
- type: :runtime
50
- version_requirements: *id002
51
- description: OmniAuth strategy for Unipass
52
- email:
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.7.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *70319452388620
37
+ - !ruby/object:Gem::Dependency
38
+ name: rake
39
+ requirement: &70319452388240 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *70319452388240
48
+ - !ruby/object:Gem::Dependency
49
+ name: simplecov
50
+ requirement: &70319452387780 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *70319452387780
59
+ description: Unipass strategy for OmniAuth 1.0
60
+ email:
53
61
  - aleksander.dabrowski@connectmedica.com
54
- - karol.sarnacki@connectmedica.pl
62
+ - sodercober@gmail.com
55
63
  executables: []
56
-
57
64
  extensions: []
58
-
59
65
  extra_rdoc_files: []
60
-
61
- files:
66
+ files:
62
67
  - .gitignore
63
- - README
68
+ - .travis.yml
69
+ - Gemfile
70
+ - LICENSE
64
71
  - README.md
72
+ - Rakefile
65
73
  - lib/omniauth-unipass.rb
66
- - lib/omniauth-unipass/version.rb
67
74
  - lib/omniauth/strategies/unipass.rb
75
+ - lib/omniauth/unipass.rb
76
+ - lib/omniauth/unipass/version.rb
68
77
  - omniauth-unipass.gemspec
69
- homepage: https://github.com/tjeden/omniauth-unipass
78
+ - spec/omniauth/strategies/unipass_spec.rb
79
+ - spec/spec_helper.rb
80
+ - spec/support/shared_examples.rb
81
+ homepage: https://github.com/connectmedica/omniauth-unipass
70
82
  licenses: []
71
-
72
83
  post_install_message:
73
84
  rdoc_options: []
74
-
75
- require_paths:
85
+ require_paths:
76
86
  - lib
77
- required_ruby_version: !ruby/object:Gem::Requirement
87
+ required_ruby_version: !ruby/object:Gem::Requirement
78
88
  none: false
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- hash: 3
83
- segments:
89
+ requirements:
90
+ - - ! '>='
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ segments:
84
94
  - 0
85
- version: "0"
86
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ hash: 4166605364702114631
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
97
  none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 3
92
- segments:
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ segments:
93
103
  - 0
94
- version: "0"
104
+ hash: 4166605364702114631
95
105
  requirements: []
96
-
97
106
  rubyforge_project:
98
- rubygems_version: 1.8.10
107
+ rubygems_version: 1.8.11
99
108
  signing_key:
100
109
  specification_version: 3
101
- summary: OmniAuth strategy for Unipass
102
- test_files: []
103
-
110
+ summary: Unipass strategy for OmniAuth 1.0
111
+ test_files:
112
+ - spec/omniauth/strategies/unipass_spec.rb
113
+ - spec/spec_helper.rb
114
+ - spec/support/shared_examples.rb
data/README DELETED
File without changes
@@ -1,5 +0,0 @@
1
- module OmniAuth
2
- module Unipass
3
- VERSION = "0.0.2"
4
- end
5
- end