omniauth-pandadoc 1.0.0rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06cfebe1fad2882a1c9e1b3fe1f2e1e0e957c881
4
+ data.tar.gz: f74be53f1ea9e5dc7346472466323b0e655bfb01
5
+ SHA512:
6
+ metadata.gz: 2fb588e165a4858fb0fbac0fee960e6531d52507f6789d3b5662c72d197e7de0229148a9c3f5bc69a9fcb0cf5b0cc5fe1b8a13a419251ed6b2016d8f4ee104ed
7
+ data.tar.gz: 278f165a6e9f7fd414c7a8d99edd16d9cb581049b8f07e126ee094790c7462daf5c9cd71e17318a447c1fc91153811f465a45aa10d4d6a919fd22d6e944ad3dc
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .ruby-gemset
7
+ .ruby-version
8
+ .rvmrc
9
+ Gemfile.lock
10
+ InstalledFiles
11
+ _yardoc
12
+ coverage
13
+ doc/
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ spec/reports
18
+ test/tmp
19
+ test/version_tmp
20
+ tmp
21
+ .powenv
22
+ .idea/
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ ClassLength:
2
+ Enabled: false
3
+ Layout/IndentHeredoc:
4
+ Enabled: false
5
+ Metrics/AbcSize:
6
+ Enabled: false
7
+ Metrics/BlockLength:
8
+ ExcludedMethods: ['describe', 'context']
9
+ Metrics/CyclomaticComplexity:
10
+ Enabled: false
11
+ Metrics/LineLength:
12
+ Enabled: false
13
+ Metrics/MethodLength:
14
+ Enabled: false
15
+ Metrics/PerceivedComplexity:
16
+ Enabled: false
17
+ Naming:
18
+ Enabled: false
19
+ Style/MutableConstant:
20
+ Enabled: false
21
+ Gemspec/RequiredRubyVersion:
22
+ Enabled: false
23
+
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update bundler
4
+ - bundle --version
5
+ - gem update --system
6
+ - gem --version
7
+ rvm:
8
+ - 2.5
9
+ - 2.4
10
+ - 2.3
11
+ - 2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ ## 1.0.0.rc1 (2018-07-12)
5
+
6
+ - first public gem release (@euanlau)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # OmniAuth Pandadoc  [![Build Status](https://secure.travis-ci.org/CatchRelease/omniauth-pandadoc.svg?branch=master)](https://travis-ci.org/CatchRelease/omniauth-pandadoc) [![Gem Version](https://img.shields.io/gem/v/omniauth-pandadoc.svg)](https://rubygems.org/gems/omniauth-pandadoc)
2
+
3
+ Pandadoc Strategy for OmniAuth.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-pandadoc'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ `OmniAuth::Strategies::Pandadoc` is simply a Rack middleware. Read the OmniAuth docs for detailed instructions: https://github.com/intridea/omniauth.
18
+
19
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use OmniAuth::Builder do
23
+ provider :pandadoc, ENV['PANDADOC_CLIENT_ID'], ENV['PANDADOC_CLIENT_SECRET']
24
+ end
25
+ ```
26
+
27
+ ## Supported Rubies
28
+
29
+ - Ruby MRI (2.2+)
30
+
31
+ ## License
32
+
33
+ Copyright (c) 2018 by Euan Lau, Mike Carey
34
+
35
+ 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:
36
+
37
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
38
+
39
+ 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,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.join('bundler', 'gem_tasks')
4
+ require File.join('rspec', 'core', 'rake_task')
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/pandadoc'
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/pandadoc/version'
4
+ require 'omniauth/strategies/pandadoc'
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Pandadoc
5
+ VERSION = '1.0.0rc1'
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require 'omniauth'
2
+ require 'omniauth-oauth2'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ # Main class for Pandadoc OAuth2 strategy.
7
+ class Pandadoc < OmniAuth::Strategies::OAuth2
8
+ DEFAULT_SCOPE = 'read+write'
9
+
10
+ option :client_options,
11
+ site: 'https://api.pandadoc.com/public/v1',
12
+ authorize_url: 'https://app.pandadoc.com/oauth2/authorize',
13
+ token_url: 'https://api.pandadoc.com/oauth2/access_token'
14
+
15
+ option :provider_ignores_state, true # this is needed for local testing
16
+
17
+ def request_phase
18
+ redirect client.auth_code.authorize_url({ redirect_uri: callback_url }.merge(options.authorize_params))
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(
4
+ File.join('..', 'lib', 'omniauth', 'pandadoc', 'version'),
5
+ __FILE__
6
+ )
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = 'omniauth-pandadoc'
10
+ gem.version = OmniAuth::Pandadoc::VERSION
11
+ gem.license = 'MIT'
12
+ gem.summary = %(Pandadoc Strategy for OmniAuth)
13
+ gem.authors = ['Mike Carey', 'Euan Lau']
14
+ gem.email = ['euanlau@gmail.com']
15
+ gem.homepage = 'https://github.com/catchandrelease/omniauth-pandadoc'
16
+
17
+ gem.files = `git ls-files`.split("\n")
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.required_ruby_version = '>= 2.2'
21
+
22
+ gem.add_runtime_dependency 'jwt', '~> 1.5'
23
+ gem.add_runtime_dependency 'omniauth', '~> 1.2'
24
+ gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.5'
25
+
26
+ gem.add_development_dependency 'rake', '~> 12.0'
27
+ gem.add_development_dependency 'rspec', '~> 3.7'
28
+ gem.add_development_dependency 'rubocop', '~> 0.58'
29
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+ require 'json'
5
+ require 'omniauth-pandadoc'
6
+
7
+ describe OmniAuth::Strategies::Pandadoc do
8
+ let(:request) { double('Request', params: {}, cookies: {}, env: {}) }
9
+ let(:app) do
10
+ lambda do
11
+ [200, {}, ['Hello.']]
12
+ end
13
+ end
14
+
15
+ subject do
16
+ OmniAuth::Strategies::Pandadoc.new(app, 'appid', 'secret', @options || {}).tap do |strategy|
17
+ allow(strategy).to receive(:request) do
18
+ request
19
+ end
20
+ end
21
+ end
22
+
23
+ before do
24
+ OmniAuth.config.test_mode = true
25
+ end
26
+
27
+ after do
28
+ OmniAuth.config.test_mode = false
29
+ end
30
+
31
+ describe '#client_options' do
32
+ it 'has correct site' do
33
+ expect(subject.client.site).to eq('https://api.pandadoc.com/public/v1')
34
+ end
35
+
36
+ it 'has correct authorize_url' do
37
+ expect(subject.client.options[:authorize_url]).to eq('https://app.pandadoc.com/oauth2/authorize')
38
+ end
39
+
40
+ it 'has correct token_url' do
41
+ expect(subject.client.options[:token_url]).to eq('https://api.pandadoc.com/oauth2/access_token')
42
+ end
43
+
44
+ describe 'overrides' do
45
+ context 'as strings' do
46
+ it 'should allow overriding the site' do
47
+ @options = { client_options: { 'site' => 'https://example.com' } }
48
+ expect(subject.client.site).to eq('https://example.com')
49
+ end
50
+
51
+ it 'should allow overriding the authorize_url' do
52
+ @options = { client_options: { 'authorize_url' => 'https://example.com' } }
53
+ expect(subject.client.options[:authorize_url]).to eq('https://example.com')
54
+ end
55
+
56
+ it 'should allow overriding the token_url' do
57
+ @options = { client_options: { 'token_url' => 'https://example.com' } }
58
+ expect(subject.client.options[:token_url]).to eq('https://example.com')
59
+ end
60
+ end
61
+
62
+ context 'as symbols' do
63
+ it 'should allow overriding the site' do
64
+ @options = { client_options: { site: 'https://example.com' } }
65
+ expect(subject.client.site).to eq('https://example.com')
66
+ end
67
+
68
+ it 'should allow overriding the authorize_url' do
69
+ @options = { client_options: { authorize_url: 'https://example.com' } }
70
+ expect(subject.client.options[:authorize_url]).to eq('https://example.com')
71
+ end
72
+
73
+ it 'should allow overriding the token_url' do
74
+ @options = { client_options: { token_url: 'https://example.com' } }
75
+ expect(subject.client.options[:token_url]).to eq('https://example.com')
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ describe '#token_params' do
82
+ it 'should include any token params passed in the :token_params option' do
83
+ @options = { token_params: { foo: 'bar', baz: 'zip' } }
84
+ expect(subject.token_params['foo']).to eq('bar')
85
+ expect(subject.token_params['baz']).to eq('zip')
86
+ end
87
+ end
88
+
89
+ describe '#token_options' do
90
+ it 'should include top-level options that are marked as :token_options' do
91
+ @options = { token_options: %i[scope foo], scope: 'bar', foo: 'baz', bad: 'not_included' }
92
+ expect(subject.token_params['scope']).to eq('bar')
93
+ expect(subject.token_params['foo']).to eq('baz')
94
+ expect(subject.token_params['bad']).to eq(nil)
95
+ end
96
+ end
97
+
98
+ describe '#callback_path' do
99
+ it 'has the correct default callback path' do
100
+ expect(subject.callback_path).to eq('/auth/pandadoc/callback')
101
+ end
102
+
103
+ it 'should set the callback_path parameter if present' do
104
+ @options = { callback_path: '/auth/foo/callback' }
105
+ expect(subject.callback_path).to eq('/auth/foo/callback')
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'spec_helper'
4
+
5
+ describe 'Rubocop' do
6
+ it 'should pass with no offenses detected' do
7
+ expect(`rubocop`).to include('no offenses detected')
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.join('bundler', 'setup')
4
+ require 'rspec'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-pandadoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0rc1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Carey
8
+ - Euan Lau
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-07-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jwt
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.2'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.2'
42
+ - !ruby/object:Gem::Dependency
43
+ name: omniauth-oauth2
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '1.5'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '1.5'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '12.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '12.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '3.7'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.7'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rubocop
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.58'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.58'
98
+ description:
99
+ email:
100
+ - euanlau@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".rubocop.yml"
107
+ - ".travis.yml"
108
+ - CHANGELOG.md
109
+ - Gemfile
110
+ - README.md
111
+ - Rakefile
112
+ - lib/omniauth-pandadoc.rb
113
+ - lib/omniauth/pandadoc.rb
114
+ - lib/omniauth/pandadoc/version.rb
115
+ - lib/omniauth/strategies/pandadoc.rb
116
+ - omniauth-pandadoc.gemspec
117
+ - spec/omniauth/strategies/pandadoc_spec.rb
118
+ - spec/rubocop_spec.rb
119
+ - spec/spec_helper.rb
120
+ homepage: https://github.com/catchandrelease/omniauth-pandadoc
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '2.2'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">"
136
+ - !ruby/object:Gem::Version
137
+ version: 1.3.1
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.13
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Pandadoc Strategy for OmniAuth
144
+ test_files: []