omniauth-cafepress 0.1.1
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/README.md +29 -0
- data/Rakefile +12 -0
- data/lib/omniauth-cafepress.rb +2 -0
- data/lib/omniauth-cafepress/version.rb +5 -0
- data/lib/omniauth/strategies/cafepress.rb +54 -0
- data/omniauth-cafepress.gemspec +25 -0
- data/spec/omniauth/strategies/cafepress_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- metadata +170 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3@omniauth-cafepress
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# OmniAuth Cafepress
|
2
|
+
|
3
|
+
This is the official OmniAuth strategy for authenticating to Cafepress. To
|
4
|
+
use it, you'll need to sign up for a developer account on the Cafepress website
|
5
|
+
(http://developer.cafepress.com/) and get an Application ID (APP_ID).
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
use OmniAuth::Builder do
|
10
|
+
provider :cafepress, 'APP_ID'
|
11
|
+
end
|
12
|
+
|
13
|
+
## License
|
14
|
+
|
15
|
+
Copyright (C) 2012 Cafepress, Inc.
|
16
|
+
|
17
|
+
This program is free software; you can redistribute it and/or
|
18
|
+
modify it under the terms of the GNU General Public License
|
19
|
+
as published by the Free Software Foundation; either version 2
|
20
|
+
of the License, or (at your option) any later version.
|
21
|
+
|
22
|
+
This program is distributed in the hope that it will be useful,
|
23
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
24
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
25
|
+
GNU General Public License for more details.
|
26
|
+
|
27
|
+
You should have received a copy of the GNU General Public License
|
28
|
+
along with this program; if not, write to the Free Software
|
29
|
+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'omniauth'
|
2
|
+
require 'faraday'
|
3
|
+
require 'multi_xml'
|
4
|
+
|
5
|
+
module OmniAuth
|
6
|
+
module Strategies
|
7
|
+
class Cafepress
|
8
|
+
include OmniAuth::Strategy
|
9
|
+
|
10
|
+
args [:app_key]
|
11
|
+
option :fields, [:email, :password]
|
12
|
+
option :uid_field, :email
|
13
|
+
option :token_url, 'http://api.cafepress.com/authentication.getUserToken.cp'
|
14
|
+
|
15
|
+
def request_phase
|
16
|
+
form = OmniAuth::Form.new(title: "User Info", url: callback_path)
|
17
|
+
options.fields.each do |field|
|
18
|
+
form.text_field field.to_s.capitalize.gsub("_", " "), field.to_s
|
19
|
+
end
|
20
|
+
form.button "Sign In"
|
21
|
+
form.to_response
|
22
|
+
end
|
23
|
+
|
24
|
+
uid do
|
25
|
+
request.params[options.uid_field.to_s]
|
26
|
+
end
|
27
|
+
|
28
|
+
info do
|
29
|
+
{
|
30
|
+
'name' => request.params['email'],
|
31
|
+
'email' => request.params['email']
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
credentials do
|
36
|
+
fail! :invalid_credentials if raw_info['value'].nil?
|
37
|
+
{
|
38
|
+
'token' => raw_info['value']
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw_info
|
43
|
+
@raw_info ||= MultiXml.parse(Faraday.get("#{options[:token_url]}?v=3&appKey=#{options[:app_key]}&email=#{request.params['email']}&password=#{request.params['password']}").body)
|
44
|
+
rescue ::MultiXml::ParseError => e
|
45
|
+
fail!(:xml_error, e)
|
46
|
+
rescue ::Faraday::Error::TimeoutError => e
|
47
|
+
fail!(:timeout, e)
|
48
|
+
rescue Exception
|
49
|
+
fail! :general_exception
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-cafepress/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Richard Hurt"]
|
6
|
+
gem.email = ["rhurt@cafepress.com"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Cafepress.}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Cafepress.}
|
9
|
+
gem.homepage = "https://github.com/cafepressdev/omniauth-cafepress"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'omniauth-cafepress'
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OmniAuth::Cafepress::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
19
|
+
gem.add_dependency 'faraday'
|
20
|
+
gem.add_dependency 'multi_xml'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
22
|
+
gem.add_development_dependency 'rack-test'
|
23
|
+
gem.add_development_dependency 'simplecov'
|
24
|
+
gem.add_development_dependency 'webmock'
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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 'webmock/rspec'
|
8
|
+
require 'omniauth'
|
9
|
+
require 'omniauth-cafepress'
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.include WebMock::API
|
13
|
+
config.include Rack::Test::Methods
|
14
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
15
|
+
end
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-cafepress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Richard Hurt
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: faraday
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: multi_xml
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
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
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.7'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.7'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rack-test
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: webmock
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: OmniAuth strategy for Cafepress.
|
127
|
+
email:
|
128
|
+
- rhurt@cafepress.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .rvmrc
|
135
|
+
- Gemfile
|
136
|
+
- README.md
|
137
|
+
- Rakefile
|
138
|
+
- lib/omniauth-cafepress.rb
|
139
|
+
- lib/omniauth-cafepress/version.rb
|
140
|
+
- lib/omniauth/strategies/cafepress.rb
|
141
|
+
- omniauth-cafepress.gemspec
|
142
|
+
- spec/omniauth/strategies/cafepress_spec.rb
|
143
|
+
- spec/spec_helper.rb
|
144
|
+
homepage: https://github.com/cafepressdev/omniauth-cafepress
|
145
|
+
licenses: []
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
152
|
+
requirements:
|
153
|
+
- - ! '>='
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
none: false
|
158
|
+
requirements:
|
159
|
+
- - ! '>='
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
requirements: []
|
163
|
+
rubyforge_project:
|
164
|
+
rubygems_version: 1.8.22
|
165
|
+
signing_key:
|
166
|
+
specification_version: 3
|
167
|
+
summary: OmniAuth strategy for Cafepress.
|
168
|
+
test_files:
|
169
|
+
- spec/omniauth/strategies/cafepress_spec.rb
|
170
|
+
- spec/spec_helper.rb
|