omniauth-createsend 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +54 -0
- data/LICENSE +19 -0
- data/README.md +21 -0
- data/Rakefile +17 -0
- data/example/Gemfile +4 -0
- data/example/Gemfile.lock +44 -0
- data/example/config.ru +28 -0
- data/lib/omniauth-createsend.rb +1 -0
- data/lib/omniauth/createsend.rb +2 -0
- data/lib/omniauth/createsend/version.rb +5 -0
- data/lib/omniauth/strategies/createsend.rb +31 -0
- data/omniauth-createsend.gemspec +23 -0
- data/spec/omniauth/strategies/createsend_spec.rb +32 -0
- data/spec/spec_helper.rb +7 -0
- metadata +119 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/intridea/omniauth-oauth2.git
|
3
|
+
revision: 032c21f2585047b8a7bb335f4f64697f0e6247ab
|
4
|
+
specs:
|
5
|
+
omniauth-oauth2 (1.1.1)
|
6
|
+
oauth2 (~> 0.8.0)
|
7
|
+
omniauth (~> 1.0)
|
8
|
+
|
9
|
+
PATH
|
10
|
+
remote: .
|
11
|
+
specs:
|
12
|
+
omniauth-createsend (0.0.1)
|
13
|
+
omniauth-oauth2 (~> 1.1)
|
14
|
+
|
15
|
+
GEM
|
16
|
+
remote: http://rubygems.org/
|
17
|
+
specs:
|
18
|
+
diff-lcs (1.1.3)
|
19
|
+
faraday (0.8.5)
|
20
|
+
multipart-post (~> 1.1)
|
21
|
+
hashie (1.2.0)
|
22
|
+
httpauth (0.2.0)
|
23
|
+
jwt (0.1.5)
|
24
|
+
multi_json (>= 1.0)
|
25
|
+
multi_json (1.5.0)
|
26
|
+
multipart-post (1.1.5)
|
27
|
+
oauth2 (0.8.0)
|
28
|
+
faraday (~> 0.8)
|
29
|
+
httpauth (~> 0.1)
|
30
|
+
jwt (~> 0.1.4)
|
31
|
+
multi_json (~> 1.0)
|
32
|
+
rack (~> 1.2)
|
33
|
+
omniauth (1.1.1)
|
34
|
+
hashie (~> 1.2)
|
35
|
+
rack
|
36
|
+
rack (1.5.1)
|
37
|
+
rake (10.0.3)
|
38
|
+
rspec (2.12.0)
|
39
|
+
rspec-core (~> 2.12.0)
|
40
|
+
rspec-expectations (~> 2.12.0)
|
41
|
+
rspec-mocks (~> 2.12.0)
|
42
|
+
rspec-core (2.12.2)
|
43
|
+
rspec-expectations (2.12.1)
|
44
|
+
diff-lcs (~> 1.1.3)
|
45
|
+
rspec-mocks (2.12.2)
|
46
|
+
|
47
|
+
PLATFORMS
|
48
|
+
ruby
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
omniauth-createsend!
|
52
|
+
omniauth-oauth2!
|
53
|
+
rake
|
54
|
+
rspec (~> 2.12)
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 James Dennes
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# OmniAuth CreateSend
|
2
|
+
|
3
|
+
This is the official OmniAuth strategy for authenticating with the [Campaign Monitor API](http://www.campaignmonitor.com/api/). The first thing you need to do is register an OAuth2 Application in your Campaign Monitor account to get a Client ID and Client Secret to use with this OmniAuth strategy.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
Add a dependency in your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-createsend'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
## Basic Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
use OmniAuth::Builder do
|
19
|
+
provider "createsend", ENV['CREATESEND_CLIENT_ID'], ENV['CREATESEND_CLIENT_SECRET']
|
20
|
+
end
|
21
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
desc "Run specs"
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
desc "Build the gem"
|
8
|
+
task :build do
|
9
|
+
system "gem build omniauth-createsend.gemspec"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Build and release the gem"
|
13
|
+
task :release => :build do
|
14
|
+
system "gem push omniauth-createsend-#{OmniAuth::CreateSend::VERSION}.gem"
|
15
|
+
end
|
16
|
+
|
17
|
+
task :default => :spec
|
data/example/Gemfile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
omniauth-createsend (0.0.1)
|
5
|
+
omniauth-oauth2 (~> 1.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
faraday (0.8.5)
|
11
|
+
multipart-post (~> 1.1)
|
12
|
+
hashie (1.2.0)
|
13
|
+
httpauth (0.2.0)
|
14
|
+
jwt (0.1.5)
|
15
|
+
multi_json (>= 1.0)
|
16
|
+
multi_json (1.5.0)
|
17
|
+
multipart-post (1.1.5)
|
18
|
+
oauth2 (0.8.0)
|
19
|
+
faraday (~> 0.8)
|
20
|
+
httpauth (~> 0.1)
|
21
|
+
jwt (~> 0.1.4)
|
22
|
+
multi_json (~> 1.0)
|
23
|
+
rack (~> 1.2)
|
24
|
+
omniauth (1.1.1)
|
25
|
+
hashie (~> 1.2)
|
26
|
+
rack
|
27
|
+
omniauth-oauth2 (1.1.1)
|
28
|
+
oauth2 (~> 0.8.0)
|
29
|
+
omniauth (~> 1.0)
|
30
|
+
rack (1.5.1)
|
31
|
+
rack-protection (1.3.2)
|
32
|
+
rack
|
33
|
+
sinatra (1.3.4)
|
34
|
+
rack (~> 1.4)
|
35
|
+
rack-protection (~> 1.3)
|
36
|
+
tilt (~> 1.3, >= 1.3.3)
|
37
|
+
tilt (1.3.3)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
omniauth-createsend!
|
44
|
+
sinatra
|
data/example/config.ru
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'omniauth-createsend'
|
4
|
+
|
5
|
+
class App < Sinatra::Base
|
6
|
+
get '/' do
|
7
|
+
redirect '/auth/createsend'
|
8
|
+
end
|
9
|
+
|
10
|
+
get '/auth/:provider/callback' do
|
11
|
+
content_type 'application/json'
|
12
|
+
MultiJson.encode(request.env)
|
13
|
+
end
|
14
|
+
|
15
|
+
get '/auth/failure' do
|
16
|
+
content_type 'application/json'
|
17
|
+
MultiJson.encode(request.env)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
use Rack::Session::Cookie
|
22
|
+
|
23
|
+
use OmniAuth::Builder do
|
24
|
+
provider :createsend, ENV['CREATESEND_CLIENT_ID'], ENV['CREATESEND_CLIENT_SECRET'],
|
25
|
+
:scope => 'ViewReports,ManageLists,CreateCampaigns,ImportSubscribers,SendCampaigns,ViewSubscribersInReports,ManageTemplates'
|
26
|
+
end
|
27
|
+
|
28
|
+
run App.new
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/createsend'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class CreateSend < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, "createsend"
|
7
|
+
option :client_options, {
|
8
|
+
:site => 'https://api.createsend.com',
|
9
|
+
:authorize_url => '/oauth',
|
10
|
+
:token_url => '/oauth/token'
|
11
|
+
}
|
12
|
+
|
13
|
+
def request_phase
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def authorize_params
|
18
|
+
super.tap do |params|
|
19
|
+
%w[scope client_options].each do |v|
|
20
|
+
if request.params[v]
|
21
|
+
params[v.to_sym] = request.params[v]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
OmniAuth.config.add_camelization 'createsend', 'CreateSend'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/createsend/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'omniauth-createsend'
|
7
|
+
s.version = OmniAuth::CreateSend::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.author = 'James Dennes'
|
10
|
+
s.email = ['jdennes@gmail.com']
|
11
|
+
s.summary = 'Official OmniAuth strategy for the Campaign Monitor API.'
|
12
|
+
s.description = 'The official OmniAuth strategy for authenticating with the Campaign Monitor API.'
|
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.1'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 2.12'
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-createsend'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::CreateSend do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::CreateSend.new({})
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#client' do
|
10
|
+
it 'should have the correct createsend site' do
|
11
|
+
subject.client.site.should eq("https://api.createsend.com")
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the correct authorization url' do
|
15
|
+
subject.client.options[:authorize_url].should eq("/oauth")
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have the correct token url' do
|
19
|
+
subject.client.options[:token_url].should eq('/oauth/token')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#callback_path' do
|
24
|
+
it 'should have the correct callback path' do
|
25
|
+
subject.callback_path.should eq('/auth/createsend/callback')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe '#authorize_params' do
|
30
|
+
# TODO: Add tests for #authorize_params
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-createsend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- James Dennes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-04 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'
|
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'
|
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.12'
|
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.12'
|
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: The official OmniAuth strategy for authenticating with the Campaign Monitor
|
63
|
+
API.
|
64
|
+
email:
|
65
|
+
- jdennes@gmail.com
|
66
|
+
executables: []
|
67
|
+
extensions: []
|
68
|
+
extra_rdoc_files: []
|
69
|
+
files:
|
70
|
+
- .gitignore
|
71
|
+
- .travis.yml
|
72
|
+
- Gemfile
|
73
|
+
- Gemfile.lock
|
74
|
+
- LICENSE
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- example/Gemfile
|
78
|
+
- example/Gemfile.lock
|
79
|
+
- example/config.ru
|
80
|
+
- lib/omniauth-createsend.rb
|
81
|
+
- lib/omniauth/createsend.rb
|
82
|
+
- lib/omniauth/createsend/version.rb
|
83
|
+
- lib/omniauth/strategies/createsend.rb
|
84
|
+
- omniauth-createsend.gemspec
|
85
|
+
- spec/omniauth/strategies/createsend_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
homepage:
|
88
|
+
licenses: []
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
segments:
|
100
|
+
- 0
|
101
|
+
hash: 500429770990697851
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
none: false
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
hash: 500429770990697851
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 1.8.24
|
114
|
+
signing_key:
|
115
|
+
specification_version: 3
|
116
|
+
summary: Official OmniAuth strategy for the Campaign Monitor API.
|
117
|
+
test_files:
|
118
|
+
- spec/omniauth/strategies/createsend_spec.rb
|
119
|
+
- spec/spec_helper.rb
|