omniauth-origo 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +33 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/lib/omniauth-origo.rb +8 -0
- data/lib/omniauth-origo/version.rb +5 -0
- data/lib/omniauth/origo.rb +1 -0
- data/lib/omniauth/strategies/origo.rb +36 -0
- data/omniauth-origo.gemspec +23 -0
- data/spec/omniauth/strategies/origo_spec.rb +30 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/shared_examples.rb +37 -0
- metadata +105 -0
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-origo (1.0.0.rc3)
|
5
|
+
multi_json
|
6
|
+
oauth
|
7
|
+
omniauth (~> 1.0.0.rc2)
|
8
|
+
omniauth-oauth (~> 1.0.0.rc2)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
hashie (1.2.0)
|
14
|
+
multi_json (1.0.3)
|
15
|
+
oauth (0.4.5)
|
16
|
+
omniauth (1.0.0)
|
17
|
+
hashie (~> 1.2)
|
18
|
+
rack
|
19
|
+
omniauth-oauth (1.0.0)
|
20
|
+
oauth
|
21
|
+
omniauth (~> 1.0)
|
22
|
+
rack (1.3.5)
|
23
|
+
simplecov (0.5.4)
|
24
|
+
multi_json (~> 1.0.3)
|
25
|
+
simplecov-html (~> 0.5.3)
|
26
|
+
simplecov-html (0.5.3)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
omniauth-origo!
|
33
|
+
simplecov
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#OmniAuth 1.0 Origo (OAuth 2) strategy
|
2
|
+
|
3
|
+
This gem is designed to work with the in-beta OmniAuth 1.0 library against Origo.no
|
4
|
+
|
5
|
+
It will not be officially released on RubyGems.org until OmniAuth 1.0 is released.
|
6
|
+
|
7
|
+
## How to include in your Gemfile
|
8
|
+
|
9
|
+
```
|
10
|
+
gem 'omniauth-origo', '~> 1.0.0.rc3', :git => 'https://github.com/origo/omniauth-origo.git'
|
11
|
+
|
12
|
+
```
|
13
|
+
|
14
|
+
##Author
|
15
|
+
|
16
|
+
Per-Kristian Nordnes <pk@origo.no>, November 2011
|
17
|
+
|
18
|
+
##License
|
19
|
+
|
20
|
+
Copyright (C) 2011 by Origogruppen AS.
|
21
|
+
|
22
|
+
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:
|
23
|
+
|
24
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
25
|
+
|
26
|
+
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/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/strategies/origo'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Origo < OmniAuth::Strategies::OAuth2
|
7
|
+
|
8
|
+
USERINFO_ENDPOINT = 'https://origo.no/-/api/v2/user/omniauth_hash'
|
9
|
+
|
10
|
+
option :name, "origo"
|
11
|
+
|
12
|
+
# TODO: make this support HTTPS when bug in Origo /-/site/check_mastersession
|
13
|
+
# is resolved. See README.md
|
14
|
+
option :client_options, {
|
15
|
+
:site => 'https://secure.origo.no',
|
16
|
+
:token_url => '/-/oauth/token',
|
17
|
+
:authorize_url => '/-/oauth/authorize'
|
18
|
+
}
|
19
|
+
|
20
|
+
uid { raw_info['uid'].to_s } # to_s to keep all values as strings
|
21
|
+
|
22
|
+
info do
|
23
|
+
raw_info['info']
|
24
|
+
end
|
25
|
+
|
26
|
+
extra do
|
27
|
+
{ 'extra' => raw_info['extra'], 'raw_info' => raw_info }
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
@raw_info ||= access_token.get(USERINFO_ENDPOINT).parsed
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth-origo/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "omniauth-origo"
|
7
|
+
gem.version = OmniAuth::Origo::VERSION
|
8
|
+
gem.authors = ["Per-Kristian Nordnes"]
|
9
|
+
gem.email = ["per.kristian.nordnes@gmail.com"]
|
10
|
+
gem.description = %q{Official OmniAuth OAuth 2 strategy for Origo.}
|
11
|
+
gem.summary = %q{Official OmniAuth OAuth 2 strategy for Origo.}
|
12
|
+
gem.homepage = "https://github.com/origo/omniauth-origo"
|
13
|
+
|
14
|
+
gem.add_runtime_dependency 'omniauth', '~> 1.0.0'
|
15
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
|
16
|
+
gem.add_runtime_dependency 'oauth'
|
17
|
+
gem.add_dependency 'multi_json'
|
18
|
+
|
19
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
gem.files = `git ls-files`.split("\n")
|
21
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Origo do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::Origo.new(nil, @options || {})
|
6
|
+
end
|
7
|
+
|
8
|
+
it_should_behave_like 'an oauth2 strategy'
|
9
|
+
|
10
|
+
describe '#client' do
|
11
|
+
it 'has correct site URL' do
|
12
|
+
subject.client.site.should == 'https://secure.origo.no'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'has correct authorize URL' do
|
16
|
+
subject.client.authorize_url.should == 'https://secure.origo.no/-/oauth/authorize'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'has correct token URL' do
|
20
|
+
subject.client.token_url.should == 'https://secure.origo.no/-/oauth/token'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#callback_path' do
|
25
|
+
it "has the correct callback path" do
|
26
|
+
subject.callback_path.should eq('/auth/origo/callback')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
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
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start
|
5
|
+
require 'rspec'
|
6
|
+
require 'rack/test'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-origo'
|
9
|
+
require 'support/shared_examples'
|
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,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 token params passed in the :token_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 :token_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
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-origo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Per-Kristian Nordnes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: &70262805584360 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70262805584360
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: omniauth-oauth2
|
27
|
+
requirement: &70262805582860 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.0
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70262805582860
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: oauth
|
38
|
+
requirement: &70262805582240 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70262805582240
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: multi_json
|
49
|
+
requirement: &70262805581260 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70262805581260
|
58
|
+
description: Official OmniAuth OAuth 2 strategy for Origo.
|
59
|
+
email:
|
60
|
+
- per.kristian.nordnes@gmail.com
|
61
|
+
executables: []
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- .rspec
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- lib/omniauth-origo.rb
|
71
|
+
- lib/omniauth-origo/version.rb
|
72
|
+
- lib/omniauth/origo.rb
|
73
|
+
- lib/omniauth/strategies/origo.rb
|
74
|
+
- omniauth-origo.gemspec
|
75
|
+
- spec/omniauth/strategies/origo_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
- spec/support/shared_examples.rb
|
78
|
+
homepage: https://github.com/origo/omniauth-origo
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.10
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Official OmniAuth OAuth 2 strategy for Origo.
|
102
|
+
test_files:
|
103
|
+
- spec/omniauth/strategies/origo_spec.rb
|
104
|
+
- spec/spec_helper.rb
|
105
|
+
- spec/support/shared_examples.rb
|