omniauth-piratenlogin 0.0.1alpha1
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.
- data/.gitignore +17 -0
- data/.travis.yml +12 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +80 -0
- data/Rakefile +7 -0
- data/lib/omniauth-piratenlogin.rb +2 -0
- data/lib/omniauth-piratenlogin/version.rb +5 -0
- data/lib/omniauth/strategies/piratenlogin.rb +48 -0
- data/omniauth-piratenlogin.gemspec +21 -0
- data/spec/omniauth/strategies/piratenlogin_spec.rb +32 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/shared_examples.rb +60 -0
- metadata +112 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2012 Roland Moriz
|
4
|
+
Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# Omniauth::Piratenlogin
|
2
|
+
|
3
|
+
|
4
|
+
[](http://travis-ci.org/rmoriz/blabla1232454)
|
5
|
+
|
6
|
+
|
7
|
+
#### (German)
|
8
|
+
|
9
|
+
Dies ist ein OmniAuth >=1.1.0 Plugin auf Basis von OAuth2 um PiratenLogin.de in die eigenen Ruby-Anwendung zu integrieren.
|
10
|
+
|
11
|
+
Weitere Informationen auf https://piratenlogin.de/developer
|
12
|
+
|
13
|
+
|
14
|
+
#### (English)
|
15
|
+
|
16
|
+
This is a strategy for OmniAuth >1.1.0 to connect a Ruby-application with PiratenLogin.de
|
17
|
+
|
18
|
+
For more information please visit https://piratenlogin.de/developer
|
19
|
+
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
Add this line to your application's Gemfile:
|
24
|
+
|
25
|
+
gem 'omniauth-piratenlogin'
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install omniauth-piratenlogin
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
```
|
38
|
+
use OmniAuth::Builder do
|
39
|
+
provider :piratenlogin, '<client id>', '<secret>'
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
## Tests
|
45
|
+
|
46
|
+
```bundle exec rake```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
(MIT License)
|
59
|
+
|
60
|
+
Copyright (c) 2012 Roland Moriz
|
61
|
+
Copyright (c) 2010-2011 Michael Bleigh and Intridea, Inc.
|
62
|
+
|
63
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
64
|
+
of this software and associated documentation files (the "Software"), to deal
|
65
|
+
in the Software without restriction, including without limitation the rights
|
66
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
67
|
+
copies of the Software, and to permit persons to whom the Software is
|
68
|
+
furnished to do so, subject to the following conditions:
|
69
|
+
|
70
|
+
The above copyright notice and this permission notice shall be included in
|
71
|
+
all copies or substantial portions of the Software.
|
72
|
+
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
74
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
75
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
76
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
77
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
78
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
79
|
+
THE SOFTWARE.
|
80
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'omniauth'
|
2
|
+
require 'omniauth/strategies/oauth2'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Piratenlogin < OmniAuth::Strategies::OAuth2
|
7
|
+
DEFAULT_SCOPE = 'public'
|
8
|
+
|
9
|
+
option :name, :piratenlogin
|
10
|
+
option :client_options, {
|
11
|
+
:site => 'https://piratenlogin.de',
|
12
|
+
:authorize_url => '/oauth/authorize'
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { raw_info['auid'] }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
# Please note:
|
20
|
+
# *ALL* fields require additional scopes
|
21
|
+
# no scope => empty value
|
22
|
+
#
|
23
|
+
'uuid' => raw_info['uuid'],
|
24
|
+
'nickname' => raw_info['nickname'],
|
25
|
+
'first_name'=> raw_info['first_name'],
|
26
|
+
'last_name' => raw_info['last_name'],
|
27
|
+
'name' => raw_info['name'],
|
28
|
+
'email' => raw_info['email']
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
extra do
|
33
|
+
{ :raw_info => raw_info }
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw_info
|
37
|
+
@raw_info ||= access_token.get('/api/v1/users/me.json').parsed
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def authorize_params
|
42
|
+
super.tap do |params|
|
43
|
+
params[:scope] ||= DEFAULT_SCOPE
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-piratenlogin/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Roland Moriz']
|
6
|
+
gem.email = ['roland@moriz.de']
|
7
|
+
gem.description = %q{OmniAuth strategy for PiratenLogin.de (OAuth2)}
|
8
|
+
gem.summary = %q{OmniAuth strategy for PiratenLogin.de (OAuth2)}
|
9
|
+
gem.homepage = 'https://github.com/softwaretechnik/omniauth-piratenlogin'
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = 'omniauth-piratenlogin'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Omniauth::Piratenlogin::VERSION
|
17
|
+
|
18
|
+
gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
|
19
|
+
gem.add_development_dependency 'rspec', '~> 2.10.0'
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-piratenlogin'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Piratenlogin do
|
5
|
+
let(:fresh_strategy){ Class.new(OmniAuth::Strategies::Piratenlogin) }
|
6
|
+
it_should_behave_like 'an oauth2 strategy'
|
7
|
+
|
8
|
+
subject do
|
9
|
+
OmniAuth::Strategies::Piratenlogin.new(nil, @options || {})
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#client' do
|
13
|
+
it 'should have the correct site' do
|
14
|
+
subject.client.site.should eq('https://piratenlogin.de')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have the correct authorization url' do
|
18
|
+
subject.client.options[:authorize_url].should eq('/oauth/authorize')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have the correct token url' do
|
22
|
+
subject.client.options[:token_url].should eq('/oauth/token')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#callback_path' do
|
27
|
+
it 'should have the correct callback path' do
|
28
|
+
subject.callback_path.should eq('/auth/piratenlogin/callback')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# NOTE (rmoriz)
|
2
|
+
# copied from https://github.com/intridea/omniauth-oauth2/blob/master/spec/omniauth/strategies/oauth2_spec.rb
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
shared_examples 'an oauth2 strategy' do
|
7
|
+
subject{ fresh_strategy }
|
8
|
+
def app; lambda{|env| [200, {}, ["Hello."]]} end
|
9
|
+
|
10
|
+
before do
|
11
|
+
OmniAuth.config.test_mode = true
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
OmniAuth.config.test_mode = false
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#client' do
|
19
|
+
it 'should be initialized with symbolized client_options' do
|
20
|
+
instance = subject.new(app, :client_options => {'authorize_url' => 'https://example.com'})
|
21
|
+
instance.client.options[:authorize_url].should == 'https://example.com'
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should set ssl options as connection options' do
|
25
|
+
instance = subject.new(app, :client_options => {'ssl' => {'ca_path' => 'foo'}})
|
26
|
+
instance.client.options[:connection_opts][:ssl] =~ {:ca_path => 'foo'}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#authorize_params' do
|
31
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
32
|
+
instance = subject.new('abc', 'def', :authorize_params => {:foo => 'bar', :baz => 'zip', :state => '123'})
|
33
|
+
instance.authorize_params.should == {'foo' => 'bar', 'baz' => 'zip', 'state' => '123', 'scope' => 'public'}
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
37
|
+
instance = subject.new('abc', 'def', :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz', :authorize_params => {:state => '123'})
|
38
|
+
instance.authorize_params.should == {'scope' => 'bar', 'foo' => 'baz', 'state' => '123'}
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should include random state in the authorize params' do
|
42
|
+
instance = subject.new('abc', 'def')
|
43
|
+
instance.authorize_params.keys.should =~ ['state', 'scope']
|
44
|
+
instance.session['omniauth.state'].should_not be_empty
|
45
|
+
instance.session['omniauth.state'].should == instance.authorize_params['state']
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#token_params' do
|
50
|
+
it 'should include any authorize params passed in the :authorize_params option' do
|
51
|
+
instance = subject.new('abc', 'def', :token_params => {:foo => 'bar', :baz => 'zip'})
|
52
|
+
instance.token_params.should == {'foo' => 'bar', 'baz' => 'zip'}
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should include top-level options that are marked as :authorize_options' do
|
56
|
+
instance = subject.new('abc', 'def', :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz')
|
57
|
+
instance.token_params.should == {'scope' => 'bar', 'foo' => 'baz'}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-piratenlogin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1alpha1
|
5
|
+
prerelease: 5
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Roland Moriz
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.10.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.10.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: OmniAuth strategy for PiratenLogin.de (OAuth2)
|
63
|
+
email:
|
64
|
+
- roland@moriz.de
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- Gemfile
|
72
|
+
- LICENSE
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/omniauth-piratenlogin.rb
|
76
|
+
- lib/omniauth-piratenlogin/version.rb
|
77
|
+
- lib/omniauth/strategies/piratenlogin.rb
|
78
|
+
- omniauth-piratenlogin.gemspec
|
79
|
+
- spec/omniauth/strategies/piratenlogin_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
- spec/support/shared_examples.rb
|
82
|
+
homepage: https://github.com/softwaretechnik/omniauth-piratenlogin
|
83
|
+
licenses: []
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
hash: -4551402171601091128
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>'
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.3.1
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 1.8.23
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: OmniAuth strategy for PiratenLogin.de (OAuth2)
|
109
|
+
test_files:
|
110
|
+
- spec/omniauth/strategies/piratenlogin_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/support/shared_examples.rb
|