omniauth-windowslive 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE +7 -0
- data/README.md +20 -0
- data/Rakefile +6 -0
- data/lib/omniauth/strategies/windowslive.rb +55 -0
- data/lib/omniauth/windowslive/version.rb +5 -0
- data/lib/omniauth/windowslive.rb +2 -0
- data/lib/omniauth-windowslive.rb +1 -0
- data/omniauth-windowslive.gemspec +25 -0
- data/spec/omniauth/strategies/windowslive_spec.rb +30 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples.rb +39 -0
- metadata +118 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.3-p0@omniauth-windowslive --create
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Joël AZÉMAR joel.azemar@gmail.com
|
2
|
+
|
3
|
+
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:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
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.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# OmniAuth Windows Live
|
2
|
+
|
3
|
+
This gem contains the unofficial WindowsLive strategy for OmniAuth.
|
4
|
+
|
5
|
+
## Basic Usage
|
6
|
+
|
7
|
+
use OmniAuth::Builder do
|
8
|
+
provider "windowslive", ENV['WINDOWSLIVE_CLIENT_ID'], ENV['WINDOWSLIVE_SECRET'], :scope => 'wl.basic'
|
9
|
+
end
|
10
|
+
|
11
|
+
## Supported Flows
|
12
|
+
|
13
|
+
for create app
|
14
|
+
# https://manage.dev.live.com/Applications/Index?wa=wsignin1.0 OR https://manage.dev.live.com/AddApplication.aspx?tou=1
|
15
|
+
|
16
|
+
## Ruby
|
17
|
+
|
18
|
+
Tested with the following Ruby versions:
|
19
|
+
|
20
|
+
- RUBY 1.9.3-p0
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
# http://msdn.microsoft.com/en-us/library/hh243647.aspx
|
4
|
+
# http://msdn.microsoft.com/en-us/library/hh243649.aspx
|
5
|
+
|
6
|
+
module OmniAuth
|
7
|
+
module Strategies
|
8
|
+
class Windowslive < OmniAuth::Strategies::OAuth2
|
9
|
+
# Scopes and permissions => http://msdn.microsoft.com/en-us/library/hh243646.aspx
|
10
|
+
DEFAULT_SCOPE = 'wl.basic,wl.emails,wl.photos'
|
11
|
+
|
12
|
+
option :client_options, {
|
13
|
+
:site => 'https://oauth.live.com',
|
14
|
+
:authorize_url => '/authorize',
|
15
|
+
:token_url => '/token'
|
16
|
+
}
|
17
|
+
|
18
|
+
option :authorize_params, {
|
19
|
+
:response_type => 'code'
|
20
|
+
}
|
21
|
+
|
22
|
+
option :name, 'windowslive'
|
23
|
+
|
24
|
+
uid { raw_info['id'] }
|
25
|
+
|
26
|
+
# http://msdn.microsoft.com/en-us/library/hh243648.aspx
|
27
|
+
info do
|
28
|
+
{
|
29
|
+
'id' => raw_info['id'],
|
30
|
+
'name' => raw_info['name'],
|
31
|
+
'first_name' => raw_info['first_name'],
|
32
|
+
'last_name' => raw_info['last_name'],
|
33
|
+
'gender' => raw_info['gender'],
|
34
|
+
'link' => raw_info['link'],
|
35
|
+
'locale' => raw_info['locale'],
|
36
|
+
'updated_time' => raw_info['updated_time']
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
extra do
|
41
|
+
{
|
42
|
+
'raw_info' => raw_info
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# http://msdn.microsoft.com/en-us/library/hh243649.aspx
|
47
|
+
def raw_info
|
48
|
+
request = 'https://apis.live.net/v5.0/me'
|
49
|
+
@raw_info ||= MultiJson.decode(access_token.get(request).body)
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
OmniAuth.config.add_camelization 'windowslive', 'Windowslive'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/windowslive'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'omniauth/windowslive/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-windowslive"
|
7
|
+
s.version = OmniAuth::Windowslive::VERSION
|
8
|
+
s.authors = ["Joel AZEMAR"]
|
9
|
+
s.email = ["joel.azemar@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/joel/omniauth-windowslive"
|
11
|
+
s.summary = 'Windows Live, Hotmail, SkyDrive, Windows Live Messenger, and other services... strategy for OmniAuth'
|
12
|
+
|
13
|
+
s.rubyforge_project = "omniauth-windowslive"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
s.add_dependency 'omniauth-oauth2', '~> 1.0'
|
21
|
+
s.add_dependency 'multi_json', '~> 1.0.3'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
23
|
+
s.add_development_dependency 'rack-test'
|
24
|
+
s.add_development_dependency 'webmock'
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-Windowslive'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Windowslive do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::Windowslive.new(nil, @options || {})
|
7
|
+
end
|
8
|
+
|
9
|
+
it_should_behave_like 'an oauth2 strategy'
|
10
|
+
|
11
|
+
describe '#client' do
|
12
|
+
it 'should have the correct Windowslive site' do
|
13
|
+
subject.client.site.should eq("https://oauth.live.com")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should have the correct authorization url' do
|
17
|
+
subject.client.options[:authorize_url].should eq("/authorize")
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should have the correct token url' do
|
21
|
+
subject.client.options[:token_url].should eq('/token')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#callback_path' do
|
26
|
+
it 'should have the correct callback path' do
|
27
|
+
subject.callback_path.should eq('/auth/windowslive/callback')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'omniauth'
|
7
|
+
require 'omniauth-windowslive'
|
8
|
+
|
9
|
+
Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# NOTE it would be useful if this lived in omniauth-oauth2 eventually
|
2
|
+
|
3
|
+
shared_examples 'an oauth2 strategy' do
|
4
|
+
describe '#client' do
|
5
|
+
it 'should be initialized with symbolized client_options' do
|
6
|
+
@options = { :client_options => { 'authorize_url' => 'https://example.com' } }
|
7
|
+
subject.client.options[:authorize_url].should == 'https://example.com'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#authorize_params' do
|
12
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
13
|
+
@options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
|
14
|
+
subject.authorize_params['foo'].should eq('bar')
|
15
|
+
subject.authorize_params['baz'].should eq('zip')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
19
|
+
@options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
20
|
+
subject.authorize_params['scope'].should eq('bar')
|
21
|
+
subject.authorize_params['foo'].should eq('baz')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#token_params' do
|
26
|
+
it 'should include any token params passed in the :token_params option' do
|
27
|
+
@options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
|
28
|
+
subject.token_params['foo'].should eq('bar')
|
29
|
+
subject.token_params['baz'].should eq('zip')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should include top-level options that are marked as :token_options' do
|
33
|
+
@options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
|
34
|
+
subject.token_params['scope'].should eq('bar')
|
35
|
+
subject.token_params['foo'].should eq('baz')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
metadata
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-windowslive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.8
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joel AZEMAR
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: &70261936328820 !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: *70261936328820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_json
|
27
|
+
requirement: &70261936325420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.3
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70261936325420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70261936324100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.7'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70261936324100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rack-test
|
49
|
+
requirement: &70261936323160 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70261936323160
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: webmock
|
60
|
+
requirement: &70261936322080 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70261936322080
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- joel.azemar@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rvmrc
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/omniauth-windowslive.rb
|
83
|
+
- lib/omniauth/strategies/windowslive.rb
|
84
|
+
- lib/omniauth/windowslive.rb
|
85
|
+
- lib/omniauth/windowslive/version.rb
|
86
|
+
- omniauth-windowslive.gemspec
|
87
|
+
- spec/omniauth/strategies/windowslive_spec.rb
|
88
|
+
- spec/spec_helper.rb
|
89
|
+
- spec/support/shared_examples.rb
|
90
|
+
homepage: https://github.com/joel/omniauth-windowslive
|
91
|
+
licenses: []
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project: omniauth-windowslive
|
110
|
+
rubygems_version: 1.8.10
|
111
|
+
signing_key:
|
112
|
+
specification_version: 3
|
113
|
+
summary: Windows Live, Hotmail, SkyDrive, Windows Live Messenger, and other services...
|
114
|
+
strategy for OmniAuth
|
115
|
+
test_files:
|
116
|
+
- spec/omniauth/strategies/windowslive_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- spec/support/shared_examples.rb
|