omniauth-quip 0.1.0

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
+ SHA256:
3
+ metadata.gz: 43b2870f0ff1ee58b78fe417c08b4faff910589f2e4ed39f71f4b73a5dfb2f3c
4
+ data.tar.gz: 84c9fc3b73095c43c31d681cfacd0e251fafb14816f604dcd5ca475118bb992b
5
+ SHA512:
6
+ metadata.gz: a6a8cf73e32d058a63e1f4c4a0585264ced2251ed5991a47268ee562b0a4d4e16729d90a1ec0c8ffe82237206d8371c413709619ed43c4e35f3c6a3608914ca2
7
+ data.tar.gz: 2deafc9bf33ec5fde93a5738ea8d0845210eb14a40ca67f90becd9f9f3adbf9614436fefcc9294f681878f61de5fbb72d06a51e44c56526ec0e2a5f8bf4557c3
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ .ruby-version
data/.rubocop.yml ADDED
@@ -0,0 +1,22 @@
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
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 - 2022-11-02
4
+
5
+ ### Added
6
+ - First version released.
7
+ - Docs in README.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,101 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-quip (0.1.0)
5
+ omniauth (>= 1.1.1)
6
+ omniauth-oauth2 (>= 1.5)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.0)
12
+ diff-lcs (1.3)
13
+ faraday (1.9.3)
14
+ faraday-em_http (~> 1.0)
15
+ faraday-em_synchrony (~> 1.0)
16
+ faraday-excon (~> 1.1)
17
+ faraday-httpclient (~> 1.0)
18
+ faraday-multipart (~> 1.0)
19
+ faraday-net_http (~> 1.0)
20
+ faraday-net_http_persistent (~> 1.0)
21
+ faraday-patron (~> 1.0)
22
+ faraday-rack (~> 1.0)
23
+ faraday-retry (~> 1.0)
24
+ ruby2_keywords (>= 0.0.4)
25
+ faraday-em_http (1.0.0)
26
+ faraday-em_synchrony (1.0.0)
27
+ faraday-excon (1.1.0)
28
+ faraday-httpclient (1.0.1)
29
+ faraday-multipart (1.0.3)
30
+ multipart-post (>= 1.2, < 3)
31
+ faraday-net_http (1.0.1)
32
+ faraday-net_http_persistent (1.2.0)
33
+ faraday-patron (1.0.0)
34
+ faraday-rack (1.0.0)
35
+ faraday-retry (1.0.3)
36
+ hashie (5.0.0)
37
+ jaro_winkler (1.5.2)
38
+ jwt (2.3.0)
39
+ multi_json (1.15.0)
40
+ multi_xml (0.6.0)
41
+ multipart-post (2.1.1)
42
+ oauth2 (1.4.7)
43
+ faraday (>= 0.8, < 2.0)
44
+ jwt (>= 1.0, < 3.0)
45
+ multi_json (~> 1.3)
46
+ multi_xml (~> 0.5)
47
+ rack (>= 1.2, < 3)
48
+ omniauth (2.0.4)
49
+ hashie (>= 3.4.6)
50
+ rack (>= 1.6.2, < 3)
51
+ rack-protection
52
+ omniauth-oauth2 (1.7.2)
53
+ oauth2 (~> 1.4)
54
+ omniauth (>= 1.9, < 3)
55
+ parallel (1.14.0)
56
+ parser (2.6.0.0)
57
+ ast (~> 2.4.0)
58
+ powerpack (0.1.2)
59
+ psych (3.1.0)
60
+ rack (2.2.3)
61
+ rack-protection (2.1.0)
62
+ rack
63
+ rainbow (3.0.0)
64
+ rake (12.3.2)
65
+ rspec (3.8.0)
66
+ rspec-core (~> 3.8.0)
67
+ rspec-expectations (~> 3.8.0)
68
+ rspec-mocks (~> 3.8.0)
69
+ rspec-core (3.8.0)
70
+ rspec-support (~> 3.8.0)
71
+ rspec-expectations (3.8.2)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.8.0)
74
+ rspec-mocks (3.8.0)
75
+ diff-lcs (>= 1.2.0, < 2.0)
76
+ rspec-support (~> 3.8.0)
77
+ rspec-support (3.8.0)
78
+ rubocop (0.65.0)
79
+ jaro_winkler (~> 1.5.1)
80
+ parallel (~> 1.10)
81
+ parser (>= 2.5, != 2.5.1.1)
82
+ powerpack (~> 0.1)
83
+ psych (>= 3.1.0)
84
+ rainbow (>= 2.2.2, < 4.0)
85
+ ruby-progressbar (~> 1.7)
86
+ unicode-display_width (~> 1.4.0)
87
+ ruby-progressbar (1.10.0)
88
+ ruby2_keywords (0.0.5)
89
+ unicode-display_width (1.4.1)
90
+
91
+ PLATFORMS
92
+ ruby
93
+
94
+ DEPENDENCIES
95
+ omniauth-quip!
96
+ rake (~> 12.0)
97
+ rspec (~> 3.6)
98
+ rubocop (~> 0.49)
99
+
100
+ BUNDLED WITH
101
+ 1.17.1
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # OmniAuth Quip OAuth2 Strategy
2
+
3
+ Strategy to authenticate with Quip via OAuth2 in OmniAuth.
4
+
5
+ Get your API key at: https://help.salesforce.com/s/articleView?id=sf.anywhere_new_api_key.htm&type=5
6
+
7
+ Note the Client ID and the Client Secret.
8
+
9
+ For more details, read the Atlassian Quip docs about OAuth 2.0 (3LO): https://quip.com/dev/automation/documentation/current#tag/Authentication
10
+
11
+ ## Installation
12
+
13
+ Add to your `Gemfile`:
14
+
15
+ ```ruby
16
+ gem 'omniauth-quip'
17
+ ```
18
+
19
+ Then `bundle install`.
20
+
21
+ ## Quip API Setup
22
+
23
+ * Go to 'https://help.salesforce.com/s/articleView?id=sf.anywhere_new_api_key.htm&type=5'
24
+ * Create a new app.
25
+ * Note the Client ID and Secret values in the App Details section.
26
+ * Under APIs and Features, add the "Authorization code grants" feature.
27
+ Configure the feature with your callback URL (something like
28
+ http://localhost:3000/auth/quip/callback).
29
+ * Under APIs and Features, add the "Quip platform REST API" API.
30
+
31
+ ## Usage
32
+
33
+ Here's an example for adding the middleware to a Rails app in
34
+ `config/initializers/omniauth.rb`:
35
+
36
+ ```ruby
37
+ Rails.application.config.middleware.use OmniAuth::Builder do
38
+ provider :quip, ENV['QUIP_CLIENT_ID'], ENV['QUIP_CLIENT_SECRET'],
39
+ scope: "USER_READ USER_WRITE USER_MANAGE"
40
+ end
41
+ ```
42
+
43
+ You can now access the OmniAuth Quip OAuth2 URL: `/auth/quip`
44
+
45
+ NOTE: While developing your application, if you change the scope in the
46
+ initializer you will need to restart your app server.
47
+
48
+ ## Auth Hash
49
+
50
+ Here's an example of an authentication hash available in the callback by
51
+ accessing `request.env['omniauth.auth']`:
52
+
53
+ After authing a user, when you make API calls over time, you should follow the
54
+ [Quip OAuth 2.0 docs](https://developer.atlassian.com/cloud/confluence/oauth-2-authorization-code-grants-3lo-for-apps/)
55
+ and continue to check the `accessible-resources` endpoint to ensure your app
56
+ continues to have access to the sites you expect.
57
+
58
+ ```ruby
59
+ {
60
+ "provider"=>"quip",
61
+ "uid"=>"1db0a817f4ad35e04d96efe06991a234238e8fa19417d39de073b6a0aa7fab677",
62
+ "info"=>{},
63
+ "credentials"=>
64
+ {"token"=>"REDACTED",
65
+ "refresh_token"=>"REDACTED",
66
+ "expires_at"=>1670017351,
67
+ "expires"=>true},
68
+ "extra"=>
69
+ {"raw_info"=>{},
70
+ "me"=>
71
+ {"name"=>"John Doe",
72
+ "emails"=>["john@acme.com"],
73
+ "id"=>"JJCAEArdcbn",
74
+ "created_usec"=>1665786610244999,
75
+ "is_robot"=>false,
76
+ "affinity"=>0.0,
77
+ "desktop_folder_id"=>"AUMAOAfZCvN",
78
+ "archive_folder_id"=>"AUMAOAOFsOu",
79
+ "starred_folder_id"=>"AUMAOAd8R4l",
80
+ "private_folder_id"=>"AUMAOA2dCE2",
81
+ "shared_folder_ids"=>[],
82
+ "group_folder_ids"=>["bNNAOAEh3Ui"],
83
+ "disabled"=>false,
84
+ "profile_picture_url"=>"https://quip-cdn.com/4OOk3BA2e412gU9Q6v3RDgDxA",
85
+ "subdomain"=>"acme",
86
+ "url"=>"https://acme.quip.com"}}
87
+ }
88
+ ```
89
+
90
+ ## License
91
+
92
+ Copyright (c) 2022 by Quentin Rousseau
93
+
94
+ 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:
95
+
96
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
97
+
98
+ 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.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Quip
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/strategies/quip'
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/strategies/oauth2'
4
+ require 'uri'
5
+
6
+ # Potential scopes: https://developer.atlassian.com/cloud/jira/platform/scopes/
7
+ # offline_access read:confluence-space.summary read:confluence-props read:confluence-content.all read:confluence-content.summary search:confluence
8
+ #
9
+ # Separate scopes with a space (%20)
10
+ # https://developer.atlassian.com/cloud/confluence/oauth-2-authorization-code-grants-3lo-for-apps/
11
+
12
+ module OmniAuth
13
+ module Strategies
14
+ # Omniauth strategy for Quip
15
+ class Quip < OmniAuth::Strategies::OAuth2
16
+
17
+ args %i[client_id client_secret]
18
+
19
+ option :name, 'quip'
20
+
21
+ option :client_options,
22
+ site: 'https://platform.quip.com/1',
23
+ authorize_url: 'https://platform.quip.com/1/oauth/login',
24
+ token_url: 'https://platform.quip.com/1/oauth/access_token'
25
+
26
+ # When `true`, client_id and client_secret are returned in extra['raw_info'].
27
+ option :extra_client_id_and_client_secret, false
28
+
29
+ def authorize_params
30
+ super.tap do |params|
31
+ %w[client_options].each do |v|
32
+ if request.params[v]
33
+ params[v.to_sym] = request.params[v]
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ def build_access_token
40
+ verifier = request.params["code"]
41
+ # Override regular client when using setup: proc
42
+ if env['omniauth.params']['client_id'] && env['omniauth.params']['client_secret']
43
+ client = ::OAuth2::Client.new(
44
+ env['omniauth.params']['client_id'],
45
+ env['omniauth.params']['client_secret'],
46
+ site: options.client_options.site,
47
+ authorize_url: options.client_options.authorize_url,
48
+ token_url: options.client_options.token_url
49
+ )
50
+ client.auth_code.get_token(verifier, {:redirect_uri => callback_url}.merge(token_params.to_hash(:symbolize_keys => true)), deep_symbolize(options.auth_token_params))
51
+ else
52
+ super
53
+ end
54
+ end
55
+
56
+ uid { Digest::SHA2.hexdigest("#{me['id']}-#{me['company_id']}-#{access_token.client.id}") }
57
+
58
+ extra do
59
+ { raw_info: raw_info, me: me }
60
+ end
61
+
62
+ def raw_info
63
+ @raw_info ||= options[:extra_client_id_and_client_secret] ? { client_id: smart_client_id, client_secret: smart_client_secret } : {}
64
+ end
65
+
66
+ def me
67
+ access_token.options[:mode] = :header
68
+ @me ||= access_token.get('users/current', :headers => { 'Content-Type' => 'application/json' }).parsed
69
+ end
70
+
71
+ def smart_client_id
72
+ @smart_client_id ||= env['omniauth.params']['client_id'] || env['omniauth.strategy'].options.client_id
73
+ end
74
+
75
+ def smart_client_secret
76
+ @smart_client_secret ||= env['omniauth.params']['client_secret'] || env['omniauth.strategy'].options.client_secret
77
+ end
78
+
79
+ def callback_url
80
+ full_host + script_name + callback_path
81
+ end
82
+ end
83
+ end
84
+ end
data/lib/quip.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth/quip'
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path(
4
+ File.join('..', 'lib', 'omniauth', 'quip', 'version'),
5
+ __FILE__
6
+ )
7
+
8
+ Gem::Specification.new do |gem|
9
+ gem.name = 'omniauth-quip'
10
+ gem.version = OmniAuth::Quip::VERSION
11
+ gem.license = 'MIT'
12
+ gem.summary = %(A Quip OAuth2 strategy for OmniAuth 1.x)
13
+ gem.description = %(A Quip OAuth2 strategy for OmniAuth 1.x. This allows you to login to Quip with your Ruby app.)
14
+ gem.authors = ['Quentin Rousseau']
15
+ gem.email = ['contact@quent.in']
16
+ gem.homepage = 'https://github.com/kwent/omniauth-quip'
17
+
18
+ gem.files = `git ls-files`.split("\n")
19
+ gem.require_paths = ['lib']
20
+
21
+ gem.required_ruby_version = '>= 2.1'
22
+
23
+ gem.add_runtime_dependency 'omniauth', '>= 1.1.1'
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.6'
28
+ gem.add_development_dependency 'rubocop', '~> 0.49'
29
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-quip
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Quentin Rousseau
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.49'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.49'
83
+ description: A Quip OAuth2 strategy for OmniAuth 1.x. This allows you to login to
84
+ Quip with your Ruby app.
85
+ email:
86
+ - contact@quent.in
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rubocop.yml"
93
+ - CHANGELOG.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - README.md
97
+ - lib/omniauth/quip.rb
98
+ - lib/omniauth/quip/version.rb
99
+ - lib/omniauth/strategies/quip.rb
100
+ - lib/quip.rb
101
+ - omniauth-quip.gemspec
102
+ homepage: https://github.com/kwent/omniauth-quip
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '2.1'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.3.3
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: A Quip OAuth2 strategy for OmniAuth 1.x
125
+ test_files: []