omniauth-passthrough 1.0.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: caa2d9412ba98d0dc313d1f92d54d5648d0168559d68bcc2ac9083f0e4b6af16
4
+ data.tar.gz: 20644c1b8d2c0ae6746fd5179a849078653a1b646ec561545677d7a5db30e6a5
5
+ SHA512:
6
+ metadata.gz: 980b0aab5c58f01141a480763134182d9a1074a0fd061c0203dd291db6922a425641991fe5a9f6229619a3bee186f3e58abf020a7ce7623b79515fe2f5e52851
7
+ data.tar.gz: 807b979a3a45f05d4b5f226b5b7618c571867965bff84fa5bc249e5cfb86e275481e9c07db3bda70770e1505110646be36b6211a83ace7c3a8f7c7b033b84dbb
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # 1.0.0 (2025-02-05)
2
+
3
+
4
+ ### Features
5
+
6
+ * action dispatch helper ([#7](https://github.com/benmelz/omniauth-passthrough/issues/7)) ([d0e6908](https://github.com/benmelz/omniauth-passthrough/commit/d0e69085944e8a7f996e14b3199630d059e9353b))
7
+ * capybara helper ([#8](https://github.com/benmelz/omniauth-passthrough/issues/8)) ([1d49bc8](https://github.com/benmelz/omniauth-passthrough/commit/1d49bc85dd8a540a24383078a1c792c29035a148))
8
+ * omniauth passthrough strategy ([#5](https://github.com/benmelz/omniauth-passthrough/issues/5)) ([f3ac6ee](https://github.com/benmelz/omniauth-passthrough/commit/f3ac6ee0fca4525e315f50ac5e96d138e1caba48))
9
+ * rack test helper ([#6](https://github.com/benmelz/omniauth-passthrough/issues/6)) ([32fd106](https://github.com/benmelz/omniauth-passthrough/commit/32fd1061cedf0758e17e44d1bdbc94f0448717d4))
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Benjamin Melz
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.
data/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # omniauth-passthrough
2
+
3
+ An OmniAuth strategy that passes request params straight through the middleware.
4
+
5
+ This strategy allows you to pass auth hash values directly to an auth endpoint and forwards them directly to your
6
+ callback(s). The end goal of this is to provide more flexibility when writing login helpers in development/test
7
+ environments while still utilizing your OmniAuth callback(s).
8
+
9
+ ## Installation
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add omniauth-passthrough
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install omniauth-passthrough
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Include the passthrough strategy in development/test environments as you would with any other OmniAuth
26
+ strategy. *NEVER* use it in a production environment.
27
+
28
+ Once included, any POST request to `/auth/passthrough` will pass through any `uid`, `info`, `credentials` and `extra`
29
+ params to your omniauth callback.
30
+
31
+ ```ruby
32
+ # request
33
+ post '/auth/passthrough', params: { uid: 'my-uid',
34
+ info: { email: 'my-email@example.com', first_name: 'My', last_name: 'Name' } }
35
+
36
+ # callback
37
+ request.env['omniauth.auth'].uid # => 'my-uid'
38
+ request.env['omniauth.auth'].info.email # => 'my-email@example.com'
39
+ request.env['omniauth.auth'].info.first_name # => 'My'
40
+ request.env['omniauth.auth'].info.last_name # => 'Name'
41
+ ```
42
+
43
+ ### Test Environments
44
+
45
+ A number of test helpers are provided to help with using the strategy for test login helpers.
46
+
47
+ ```ruby
48
+ # including one of the following helpers in your test
49
+ include Omniauth::Passthrough::RackHelper # if using Rack::Test
50
+ include Omniauth::Passthrough::ActionDispatchHelper # if using ActionDispatch (Rails)
51
+ include Omniauth::Passthrough::CapybaraHelper # if using Capybara
52
+
53
+ # will make the following login helper available
54
+ omniauth_passthrough(uid: 'my-uid', info: { email: 'my-email@example.com', first_name: 'My', last_name: 'Name' })
55
+ ```
56
+
57
+ ## Development
58
+
59
+ * Run `bin/setup` to install dependencies.
60
+ * Run `bin/rake appraisal spec` to run the tests.
61
+ * Run `bin/rake rubocop` to run the linter.
62
+ * Run `bin/console` for an interactive prompt that will allow you to experiment.
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/omniauth-passthrough.
67
+
68
+ ## License
69
+
70
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Passthrough
5
+ module ActionDispatchHelper
6
+ def omniauth_passthrough(params = {})
7
+ get("/auth/passthrough/callback", params:)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Passthrough
5
+ module CapybaraHelper
6
+ def omniauth_passthrough(params = {})
7
+ original_url = current_url
8
+ visit "/auth/passthrough/callback?#{Rack::Utils.build_nested_query(params)}"
9
+ visit original_url
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Passthrough
5
+ module RackHelper
6
+ def omniauth_passthrough(params = {})
7
+ get "/auth/passthrough/callback", params
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module Passthrough
5
+ VERSION = "1.0.0"
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "passthrough/action_dispatch_helper"
4
+ require_relative "passthrough/capybara_helper"
5
+ require_relative "passthrough/rack_helper"
6
+ require_relative "passthrough/version"
7
+ require_relative "strategies/passthrough"
8
+
9
+ module OmniAuth
10
+ module Passthrough
11
+ end
12
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omniauth"
4
+ require "rack/utils"
5
+
6
+ module OmniAuth
7
+ module Strategies
8
+ class Passthrough
9
+ include OmniAuth::Strategy
10
+
11
+ def request_phase
12
+ redirect(URI.parse(callback_url).tap { |uri| uri.query = Rack::Utils.build_nested_query(request.params) }.to_s)
13
+ end
14
+
15
+ uid { request.params["uid"] }
16
+ info { request.params["info"] || {} }
17
+ credentials { request.params["credentials"] || {} }
18
+ extra { request.params["extra"] || {} }
19
+ end
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-passthrough
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Benjamin Melz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-02-05 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: 2.1.1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.1.1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rack
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 2.2.3
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.2.3
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4'
53
+ description: 'This strategy allows you to pass auth hash values directly to an auth
54
+ endpoint and forwards them directly to your callback(s). The end goal of this is
55
+ to provide more flexibility when writing login helpers in development/test environments
56
+ while still utilizing your OmniAuth callback(s). '
57
+ email: ben@melz.me
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - LICENSE.md
64
+ - README.md
65
+ - lib/omniauth/passthrough.rb
66
+ - lib/omniauth/passthrough/action_dispatch_helper.rb
67
+ - lib/omniauth/passthrough/capybara_helper.rb
68
+ - lib/omniauth/passthrough/rack_helper.rb
69
+ - lib/omniauth/passthrough/version.rb
70
+ - lib/omniauth/strategies/passthrough.rb
71
+ homepage: https://github.com/benmelz/omniauth-passthrough
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://github.com/benmelz/omniauth-passthrough
76
+ source_code_uri: https://github.com/benmelz/omniauth-passthrough
77
+ changelog_uri: https://github.com/benmelz/omniauth-passthrough/blob/v1.0.0/CHANGELOG.md
78
+ rubygems_mfa_required: 'true'
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '3.2'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubygems_version: 3.4.19
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: An OmniAuth strategy that passes request params straight through the middleware.
98
+ test_files: []