omniauth-proxy 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 844924b13b161352ad3094228ef0f6e96c2588900311a903ca127dbc5f657538
4
+ data.tar.gz: 15448692a7ac114f8ad748e59119e4716a84d114e3c8d5f335e658f64b6abeee
5
+ SHA512:
6
+ metadata.gz: d5352ccb33e928fa5ed809d3d76d8c22b6a9f78ea31e142d7318ce9e71e94292b7f9e3b3d28a8a25e9628020daa80721860a1e83ceb4044479134d686aedba2b
7
+ data.tar.gz: e5de375875e4d1362df6dc8095df59c72828e133cecf8f37f8d769f774c0c39336ff8f35ad7f9dbb42e809c9ed3ef09a204591af64c69fc2d417a6703cabc69a
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Yuva
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # OmniauthProxy
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'omniauth_proxy'
12
+ ```
13
+
14
+ And then execute:
15
+ ```bash
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+ ```bash
21
+ $ gem install omniauth_proxy
22
+ ```
23
+
24
+ ## Contributing
25
+ Contribution directions go here.
26
+
27
+ ## License
28
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'OmniauthProxy'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1 @@
1
+ require "omniauth_proxy"
@@ -0,0 +1,38 @@
1
+ module OmniAuth
2
+ module Strategies
3
+ class Proxy
4
+ PROXY_PATH = "https://oproxy.herokuapp.com/proxy"
5
+
6
+ def initialize(app, _options={})
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ status, headers, body = @app.call(env)
12
+
13
+ if ENV["OMNIAUTH_PROXY_ENABLED"].present? && status == 302
14
+ location = headers["Location"]
15
+
16
+ if is_google?(location) || is_github?(location)
17
+ headers["Location"] = proxy_uri(location)
18
+ end
19
+ end
20
+
21
+ [status, headers, body]
22
+ end
23
+
24
+ def is_google?(location)
25
+ location.match?("https://accounts.google.com/o/oauth2/auth")
26
+ end
27
+
28
+ def is_github?(location)
29
+ location.match?("https://github.com/login/oauth/authorize")
30
+ end
31
+
32
+ def proxy_uri(location)
33
+ encoded_uri = Base64.urlsafe_encode64(location)
34
+ PROXY_PATH + "?uri=" + encoded_uri
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,18 @@
1
+ require "omniauth_proxy/railtie"
2
+ require "omniauth/strategies/proxy"
3
+
4
+ if ENV["OMNIAUTH_PROXY_ENABLED"].present?
5
+ if defined?(OmniAuth::Strategies::GitHub)
6
+ p "Patching GitHub OmniAuth Strategy"
7
+
8
+ class OmniAuth::Strategies::GitHub
9
+ def callback_url
10
+ request.params['redirect_uri'] || super
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+
17
+ module OmniauthProxy
18
+ end
@@ -0,0 +1,4 @@
1
+ module OmniauthProxy
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module OmniauthProxy
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :omniauth_proxy do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-proxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yuva
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-03-01 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.9'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.9'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: omniauth-oauth2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.6'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.0'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.6'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.0'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rails
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 6.0.2
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 6.0.2.1
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 6.0.2
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 6.0.2.1
73
+ description: Simplifies OAuth setup for review apps.
74
+ email:
75
+ - yuva@codemancers.com
76
+ executables: []
77
+ extensions: []
78
+ extra_rdoc_files: []
79
+ files:
80
+ - MIT-LICENSE
81
+ - README.md
82
+ - Rakefile
83
+ - lib/omniauth-proxy.rb
84
+ - lib/omniauth/strategies/proxy.rb
85
+ - lib/omniauth_proxy.rb
86
+ - lib/omniauth_proxy/railtie.rb
87
+ - lib/omniauth_proxy/version.rb
88
+ - lib/tasks/omniauth_proxy_tasks.rake
89
+ homepage: https://oproxy.herokuapp.com
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubygems_version: 3.1.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Proxy OmniAuth request/callback cycles.
112
+ test_files: []