omniauth-forge 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in omniauth-forge.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 12.0"
9
+ gem "rspec", "~> 3.0"
@@ -0,0 +1,206 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-forge (0.1.0)
5
+ omniauth
6
+ omniauth-oauth2
7
+ omniauth-rails_csrf_protection (~> 0.1)
8
+ zeitwerk (~> 2)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actionpack (6.1.0)
14
+ actionview (= 6.1.0)
15
+ activesupport (= 6.1.0)
16
+ rack (~> 2.0, >= 2.0.9)
17
+ rack-test (>= 0.6.3)
18
+ rails-dom-testing (~> 2.0)
19
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
+ actionview (6.1.0)
21
+ activesupport (= 6.1.0)
22
+ builder (~> 3.1)
23
+ erubi (~> 1.4)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
+ activesupport (6.1.0)
27
+ concurrent-ruby (~> 1.0, >= 1.0.2)
28
+ i18n (>= 1.6, < 2)
29
+ minitest (>= 5.1)
30
+ tzinfo (~> 2.0)
31
+ zeitwerk (~> 2.3)
32
+ addressable (2.7.0)
33
+ public_suffix (>= 2.0.2, < 5.0)
34
+ ast (2.4.1)
35
+ builder (3.2.4)
36
+ bundler-audit (0.7.0.1)
37
+ bundler (>= 1.2.0, < 3)
38
+ thor (>= 0.18, < 2)
39
+ byebug (11.1.3)
40
+ childprocess (4.0.0)
41
+ coderay (1.1.3)
42
+ concurrent-ruby (1.1.7)
43
+ crack (0.4.4)
44
+ crass (1.0.6)
45
+ diff-lcs (1.4.4)
46
+ dip (6.1.0)
47
+ thor (>= 0.20, < 1.1)
48
+ docile (1.3.2)
49
+ dotenv (2.7.6)
50
+ erubi (1.10.0)
51
+ faker (2.15.1)
52
+ i18n (>= 1.6, < 2)
53
+ faraday (1.1.0)
54
+ multipart-post (>= 1.2, < 3)
55
+ ruby2_keywords
56
+ hashdiff (1.0.1)
57
+ hashie (4.1.0)
58
+ i18n (1.8.5)
59
+ concurrent-ruby (~> 1.0)
60
+ iniparse (1.5.0)
61
+ jwt (2.2.2)
62
+ loofah (2.8.0)
63
+ crass (~> 1.0.2)
64
+ nokogiri (>= 1.5.9)
65
+ method_source (1.0.0)
66
+ mini_portile2 (2.4.0)
67
+ minitest (5.14.2)
68
+ multi_json (1.15.0)
69
+ multi_xml (0.6.0)
70
+ multipart-post (2.1.1)
71
+ mustermann (1.1.1)
72
+ ruby2_keywords (~> 0.0.1)
73
+ nio4r (2.5.4)
74
+ nokogiri (1.10.10)
75
+ mini_portile2 (~> 2.4.0)
76
+ oauth2 (1.4.4)
77
+ faraday (>= 0.8, < 2.0)
78
+ jwt (>= 1.0, < 3.0)
79
+ multi_json (~> 1.3)
80
+ multi_xml (~> 0.5)
81
+ rack (>= 1.2, < 3)
82
+ omniauth (1.9.1)
83
+ hashie (>= 3.4.6)
84
+ rack (>= 1.6.2, < 3)
85
+ omniauth-oauth2 (1.7.0)
86
+ oauth2 (~> 1.4)
87
+ omniauth (~> 1.9)
88
+ omniauth-rails_csrf_protection (0.1.2)
89
+ actionpack (>= 4.2)
90
+ omniauth (>= 1.3.1)
91
+ overcommit (0.57.0)
92
+ childprocess (>= 0.6.3, < 5)
93
+ iniparse (~> 1.4)
94
+ parallel (1.20.1)
95
+ parser (2.7.2.0)
96
+ ast (~> 2.4.1)
97
+ pry (0.13.1)
98
+ coderay (~> 1.1)
99
+ method_source (~> 1.0)
100
+ pry-byebug (3.9.0)
101
+ byebug (~> 11.0)
102
+ pry (~> 0.13.0)
103
+ public_suffix (4.0.6)
104
+ puma (5.1.1)
105
+ nio4r (~> 2.0)
106
+ rack (2.2.3)
107
+ rack-protection (2.1.0)
108
+ rack
109
+ rack-test (1.1.0)
110
+ rack (>= 1.0, < 3)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.3.0)
115
+ loofah (~> 2.3)
116
+ rainbow (3.0.0)
117
+ rake (12.3.3)
118
+ regexp_parser (2.0.0)
119
+ rexml (3.2.4)
120
+ rspec (3.10.0)
121
+ rspec-core (~> 3.10.0)
122
+ rspec-expectations (~> 3.10.0)
123
+ rspec-mocks (~> 3.10.0)
124
+ rspec-core (3.10.0)
125
+ rspec-support (~> 3.10.0)
126
+ rspec-expectations (3.10.0)
127
+ diff-lcs (>= 1.2.0, < 2.0)
128
+ rspec-support (~> 3.10.0)
129
+ rspec-mocks (3.10.0)
130
+ diff-lcs (>= 1.2.0, < 2.0)
131
+ rspec-support (~> 3.10.0)
132
+ rspec-support (3.10.0)
133
+ rubocop (1.6.1)
134
+ parallel (~> 1.10)
135
+ parser (>= 2.7.1.5)
136
+ rainbow (>= 2.2.2, < 4.0)
137
+ regexp_parser (>= 1.8, < 3.0)
138
+ rexml
139
+ rubocop-ast (>= 1.2.0, < 2.0)
140
+ ruby-progressbar (~> 1.7)
141
+ unicode-display_width (>= 1.4.0, < 2.0)
142
+ rubocop-ast (1.3.0)
143
+ parser (>= 2.7.1.5)
144
+ rubocop-faker (1.1.0)
145
+ faker (>= 2.12.0)
146
+ rubocop (>= 0.82.0)
147
+ rubocop-performance (1.9.1)
148
+ rubocop (>= 0.90.0, < 2.0)
149
+ rubocop-ast (>= 0.4.0)
150
+ ruby-progressbar (1.10.1)
151
+ ruby2_keywords (0.0.2)
152
+ simplecov (0.20.0)
153
+ docile (~> 1.1)
154
+ simplecov-html (~> 0.11)
155
+ simplecov_json_formatter (~> 0.1)
156
+ simplecov-html (0.12.3)
157
+ simplecov-rcov (0.2.3)
158
+ simplecov (>= 0.4.1)
159
+ simplecov_json_formatter (0.1.2)
160
+ sinatra (2.1.0)
161
+ mustermann (~> 1.0)
162
+ rack (~> 2.2)
163
+ rack-protection (= 2.1.0)
164
+ tilt (~> 2.0)
165
+ thor (1.0.1)
166
+ tilt (2.0.10)
167
+ timecop (0.9.2)
168
+ tzinfo (2.0.3)
169
+ concurrent-ruby (~> 1.0)
170
+ unicode-display_width (1.7.0)
171
+ vcr (6.0.0)
172
+ webmock (3.10.0)
173
+ addressable (>= 2.3.6)
174
+ crack (>= 0.3.2)
175
+ hashdiff (>= 0.4.0, < 2.0.0)
176
+ yard (0.9.25)
177
+ zeitwerk (2.4.2)
178
+
179
+ PLATFORMS
180
+ ruby
181
+
182
+ DEPENDENCIES
183
+ bundler
184
+ bundler-audit
185
+ dip
186
+ dotenv
187
+ faker
188
+ omniauth-forge!
189
+ overcommit
190
+ pry-byebug
191
+ puma
192
+ rake (~> 12.0)
193
+ rspec (~> 3.0)
194
+ rubocop
195
+ rubocop-faker
196
+ rubocop-performance
197
+ simplecov
198
+ simplecov-rcov
199
+ sinatra
200
+ timecop
201
+ vcr
202
+ webmock
203
+ yard
204
+
205
+ BUNDLED WITH
206
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Denis <Zaratan> Pasin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Omniauth::Forge
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/omniauth/forge`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'omniauth-forge'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-forge
22
+
23
+ ## CVE
24
+
25
+ See [Omniauth Wiki][https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284].
26
+ There's an existing unfixed CVE on omniauth. This CVE is mitigated in Rails by using the gem [omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection).
27
+ This gem will depend on that gem in order to protect as many people as possible.
28
+
29
+ ### Using bundle audit
30
+
31
+ Since the gem will be used by default you can ignore bundle audit warnings this way:
32
+ ```sh
33
+ bundle audit check --ignore CVE-2015-9284
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ TODO: Write usage instructions here
39
+
40
+ ## Development
41
+
42
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
43
+
44
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome on GitHub at https://github.com/denispasin/omniauth-forge. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/denispasin/omniauth-forge/blob/master/CODE_OF_CONDUCT.md).
49
+
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
54
+
55
+ ## Code of Conduct
56
+
57
+ Everyone interacting in the Omniauth::Forge project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/denispasin/omniauth-forge/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "omniauth/forge"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'sinatra'
5
+ require 'dotenv/load'
6
+ require "bundler/setup"
7
+ require "omniauth-forge"
8
+
9
+ use Rack::Session::Cookie
10
+
11
+ use OmniAuth::Builder do
12
+ provider :forge,
13
+ ENV['FORGE_CLIENT_ID'],
14
+ ENV['FORGE_CLIENT_SECRET'],
15
+ {
16
+ client_options: { site: ENV['FORGE_API_BASE_URL'] },
17
+ root_uri: ENV['ROOT_URI'],
18
+ }
19
+ end
20
+
21
+ get '/forge/callback' do
22
+ request.env["omniauth.auth"]["info"].to_json
23
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "zeitwerk"
4
+
5
+ require 'omniauth'
6
+ require 'omniauth-oauth2'
7
+
8
+ # module OmniAuth
9
+ # module Forge
10
+ # end
11
+ # end
12
+
13
+ loader = Zeitwerk::Loader.for_gem
14
+
15
+ loader.inflector.inflect(
16
+ "omniauth" => "OmniAuth",
17
+ "omniauth-forge" => "OmniAuthForge"
18
+ )
19
+
20
+ loader.setup # ready!
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Forge < OmniAuth::Strategies::OAuth2
6
+ option :name, 'forge'
7
+
8
+ option(
9
+ :client_options,
10
+ {
11
+ site: 'https://developer.api.autodesk.com',
12
+ authorize_url: '/authentication/v1/authorize',
13
+ token_url: '/authentication/v1/gettoken',
14
+ }
15
+ )
16
+
17
+ option :callback_path, '/forge/callback'
18
+ option :root_uri, 'https://localhost'
19
+
20
+ uid do
21
+ raw_info['userId']
22
+ end
23
+
24
+ info do
25
+ {
26
+ user_name: raw_info['userName'],
27
+ email: raw_info['emailId'],
28
+ first_name: raw_info['firstName'],
29
+ last_name: raw_info['lastName'],
30
+ }
31
+ end
32
+
33
+ extra do
34
+ {
35
+ 'raw_info' => raw_info,
36
+ }
37
+ end
38
+
39
+ def raw_info
40
+ @raw_info ||= access_token.get('/userprofile/v1/users/@me').parsed
41
+ end
42
+
43
+ def initialize(app, *args, &block)
44
+ super
45
+ if @options&.[](:client_options)&.[](:redirect_uri) &&
46
+ @options[:client_options][:redirect_uri] != self.class.default_options[:client_options][:redirect_uri]
47
+ return
48
+ end
49
+
50
+ @options[:client_options][:redirect_uri] =
51
+ "#{@options[:root_uri].to_s.gsub(%r{/+$}, '')}/#{options[:callback_path].to_s.gsub(%r{^/+}, '')}"
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Forge
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/omniauth_forge/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'omniauth-forge'
7
+ spec.version = OmniAuth::Forge::VERSION
8
+ spec.authors = ['Denis <Zaratan> Pasin']
9
+ spec.email = ['denis.pasin@autodesk.com']
10
+
11
+ spec.summary = "Connect to Autodesk's forge with omniauth strategy"
12
+ spec.description = 'Omniauth oauth2 strategy to connect to https://forge.autodesk.com'
13
+ spec.homepage = "https://github.com/shotgunsoftware/omniauth-forge"
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0')
16
+
17
+ spec.metadata['homepage_uri'] = spec.homepage
18
+ spec.metadata['source_code_uri'] = spec.homepage
19
+ spec.metadata['changelog_uri'] = "https://github.com/shotgunsoftware/omniauth-forge/blob/main/CHANGELOG.md"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files =
24
+ Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'omniauth'
32
+ spec.add_dependency 'omniauth-oauth2'
33
+ spec.add_dependency 'omniauth-rails_csrf_protection', '~> 0.1' # No CVE-2015-9284
34
+ spec.add_dependency 'zeitwerk', '~> 2'
35
+
36
+ spec.add_development_dependency 'bundler'
37
+ spec.add_development_dependency 'bundler-audit'
38
+ spec.add_development_dependency 'dip'
39
+ spec.add_development_dependency 'dotenv'
40
+ spec.add_development_dependency 'faker'
41
+ spec.add_development_dependency 'overcommit'
42
+ spec.add_development_dependency 'pry-byebug'
43
+ spec.add_development_dependency 'puma'
44
+ spec.add_development_dependency 'rake'
45
+ spec.add_development_dependency 'rspec'
46
+ spec.add_development_dependency 'rubocop'
47
+ spec.add_development_dependency 'rubocop-faker'
48
+ spec.add_development_dependency 'rubocop-performance'
49
+ spec.add_development_dependency 'simplecov'
50
+ spec.add_development_dependency 'simplecov-rcov'
51
+ spec.add_development_dependency 'sinatra'
52
+ spec.add_development_dependency 'timecop'
53
+ spec.add_development_dependency 'vcr'
54
+ spec.add_development_dependency 'webmock'
55
+ spec.add_development_dependency 'yard'
56
+ end