omniauth-wordpress 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/README +0 -0
- data/Rakefile +6 -0
- data/lib/omniauth/strategies/wordpress.rb +42 -0
- data/lib/omniauth/wordpress/version.rb +5 -0
- data/lib/omniauth/wordpress.rb +2 -0
- data/lib/omniauth-wordpress.rb +1 -0
- data/omniauth-wordpress.gemspec +25 -0
- data/spec/omniauth/strategies/wordpress_spec.rb +38 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/shared_examples.rb +37 -0
- metadata +112 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
class OmniAuth::Strategies::Wordpress < OmniAuth::Strategies::OAuth2
|
5
|
+
option :name, "wordpress"
|
6
|
+
option :client_options, {
|
7
|
+
:site => "https://public-api.wordpress.com",
|
8
|
+
:authorize_url => 'https://public-api.wordpress.com/oauth2/authorize',
|
9
|
+
:token_url => 'https://public-api.wordpress.com/oauth2/token'
|
10
|
+
}
|
11
|
+
|
12
|
+
option :token_params, {
|
13
|
+
:parse => :json
|
14
|
+
}
|
15
|
+
|
16
|
+
uid { access_token.params['blog_id'] }
|
17
|
+
|
18
|
+
info do
|
19
|
+
{
|
20
|
+
:uid => access_token.params['blog_id'],
|
21
|
+
:blog_url => access_token.params['blog_url'],
|
22
|
+
:nickname => raw_info['username'],
|
23
|
+
:name => raw_info['display_name'],
|
24
|
+
:user_id => access_token['ID'],
|
25
|
+
:image => raw_info['avatar_URL'],
|
26
|
+
:website => raw_info['profile_URL'],
|
27
|
+
:email => raw_info['email']
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
extra do
|
32
|
+
{'raw_info' => raw_info.merge(access_token.params)}
|
33
|
+
end
|
34
|
+
|
35
|
+
def raw_info
|
36
|
+
@raw_info ||= MultiJson.decode(access_token.get('/rest/v1/me').body)
|
37
|
+
rescue ::Errno::ETIMEDOUT
|
38
|
+
raise ::Timeout::Error
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/wordpress'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth/wordpress/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-wordpress"
|
7
|
+
s.version = Omniauth::Wordpress::VERSION
|
8
|
+
s.authors = ["Magda Sikorska"]
|
9
|
+
s.email = ["madzia.sikorska@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/elrosa/omniauth-wordpress"
|
11
|
+
s.summary = 'Wordpress strategy for OmniAuth.'
|
12
|
+
s.description = 'Wordpress strategy for OmniAuth.'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.7.0'
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'webmock'
|
24
|
+
s.add_development_dependency 'rack-test'
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-wordpress'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Wordpress do
|
5
|
+
before :each do
|
6
|
+
@request = double('Request')
|
7
|
+
@request.stub(:params) { {} }
|
8
|
+
@request.stub(:cookies) { {} }
|
9
|
+
@request.stub(:env) { {} }
|
10
|
+
|
11
|
+
@client_id = '123'
|
12
|
+
@client_secret = '53cr3tz'
|
13
|
+
end
|
14
|
+
|
15
|
+
subject do
|
16
|
+
args = [@client_id, @client_secret, @options].compact
|
17
|
+
OmniAuth::Strategies::Wordpress.new(nil, *args).tap do |strategy|
|
18
|
+
strategy.stub(:request) { @request }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it_should_behave_like 'an oauth2 strategy'
|
23
|
+
|
24
|
+
describe '#client' do
|
25
|
+
it 'has correct Wordpress site' do
|
26
|
+
subject.client.site.should eq('https://public-api.wordpress.com')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'has correct authorize url' do
|
30
|
+
subject.client.options[:authorize_url].should eq('https://public-api.wordpress.com/oauth2/authorize')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'has correct token url' do
|
34
|
+
subject.client.options[:token_url].should eq('https://public-api.wordpress.com/oauth2/token')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-wordpress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Magda Sikorska
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: &21454760 !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: *21454760
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &21453980 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 2.7.0
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *21453980
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &21453100 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *21453100
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: webmock
|
49
|
+
requirement: &21452600 !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: *21452600
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
requirement: &21452160 !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: *21452160
|
69
|
+
description: Wordpress strategy for OmniAuth.
|
70
|
+
email:
|
71
|
+
- madzia.sikorska@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- README
|
79
|
+
- Rakefile
|
80
|
+
- lib/omniauth-wordpress.rb
|
81
|
+
- lib/omniauth/strategies/wordpress.rb
|
82
|
+
- lib/omniauth/wordpress.rb
|
83
|
+
- lib/omniauth/wordpress/version.rb
|
84
|
+
- omniauth-wordpress.gemspec
|
85
|
+
- spec/omniauth/strategies/wordpress_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
- spec/support/shared_examples.rb
|
88
|
+
homepage: https://github.com/elrosa/omniauth-wordpress
|
89
|
+
licenses: []
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
none: false
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 1.8.11
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: Wordpress strategy for OmniAuth.
|
112
|
+
test_files: []
|