omniauth-jets_csrf_protection 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: 8b9588c379677f5371b3d98fa53f792c54d1eb40c17ae94680392f19a93d40f1
4
+ data.tar.gz: 738c44783c5614d4e666642b113398352b9ddc7baa47825320ab0e7dcd1c3b16
5
+ SHA512:
6
+ metadata.gz: e81b47383050bfe65153723eae2624549a6ba1e9340368b477cf94bf1a260aed8e827abddb6eb39b6397d22ea78de0834dc78220484758c3e0472833f13e2159
7
+ data.tar.gz: 6fa14a6d02a404e8738d5a2f8050c7c50558520dc2e1d89cc683e133ec8c7a1e222262c202cea1e9420757477f17724d667d7ee9f5c41127f65cca5a161a4b5d
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Tung Nguyen
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,16 @@
1
+ # Omniauth - Jets CSRF Protection
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/omniauth-jets_csrf_protection.png)](http://badge.fury.io/rb/omniauth-jets_csrf_protection)
4
+
5
+ [![BoltOps Badge](https://img.boltops.com/boltops/badges/boltops-badge.png)](https://www.boltops.com)
6
+
7
+ [![BoltOps Learn Badge](https://img.boltops.com/boltops-learn/boltops-learn.png)](https://learn.boltops.com)
8
+
9
+
10
+ This gem provides protection against [CVE-2015-9284] (Cross-Site Request
11
+ Forgery on the request phase when using OmniAuth gem with a Ruby on Jets
12
+ application) for Jets applications using OmniAuth gem. It achieves this by integrating a CSRF token verifier that leverages the `ActionController::RequestForgeryProtection`.
13
+
14
+ [CVE-2015-9284]: https://nvd.nist.gov/vuln/detail/CVE-2015-9284
15
+
16
+ This is a fork of [cookpad/omniauth-rails_csrf_protection](https://github.com/cookpad/omniauth-rails_csrf_protection). Credit goes to the original authors of that gem.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,44 @@
1
+ require "active_support/configurable"
2
+ require "action_controller"
3
+
4
+ module OmniAuth
5
+ module JetsCsrfProtection
6
+ # Provides a callable method that verifies Cross-Site Request Forgery
7
+ # protection token. This class includes
8
+ # `ActionController::RequestForgeryProtection` directly and utilizes
9
+ # `verified_request?` method to match the way Jets performs token
10
+ # verification in Jets controllers.
11
+ #
12
+ # If you like to learn more about how Jets generate and verify
13
+ # authenticity token, you can find the source code at
14
+ # https://github.com/rails/rails/blob/v5.2.2/actionpack/lib/action_controller/metal/request_forgery_protection.rb#L217-L240.
15
+ class TokenVerifier
16
+ include ActiveSupport::Configurable
17
+ include ActionController::RequestForgeryProtection
18
+
19
+ # `ActionController::RequestForgeryProtection` contains a few
20
+ # configurable options. As we want to make sure that our configuration is
21
+ # the same as what being set in `ActionController::Base`, we should make
22
+ # all out configuration methods to delegate to `ActionController::Base`.
23
+ config.each_key do |configuration_name|
24
+ undef_method configuration_name
25
+ define_method configuration_name do
26
+ ActionController::Base.config[configuration_name]
27
+ end
28
+ end
29
+
30
+ def call(env)
31
+ @request = env['jets.controller'].request
32
+
33
+ unless verified_request?
34
+ raise ActionController::InvalidAuthenticityToken
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ attr_reader :request
41
+ delegate :params, :session, to: :request
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,12 @@
1
+ require "omniauth"
2
+ require "omniauth/jets_csrf_protection/token_verifier"
3
+
4
+ module OmniAuth
5
+ module JetsCsrfProtection
6
+ class Turbine < Jets::Turbine
7
+ initializer "omniauth-jets_csrf_protection.initialize" do
8
+ OmniAuth.config.request_validation_phase = TokenVerifier.new
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Omniauth
4
+ module JetsCsrfProtection
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "jets_csrf_protection/version"
4
+ require_relative "jets_csrf_protection/turbine"
5
+
6
+ module Omniauth
7
+ module JetsCsrfProtection
8
+ class Error < StandardError; end
9
+ # Your code goes here...
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-jets_csrf_protection
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tung Nguyen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionpack
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jets
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - tongueroo@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - README.md
92
+ - Rakefile
93
+ - lib/omniauth/jets_csrf_protection.rb
94
+ - lib/omniauth/jets_csrf_protection/token_verifier.rb
95
+ - lib/omniauth/jets_csrf_protection/turbine.rb
96
+ - lib/omniauth/jets_csrf_protection/version.rb
97
+ homepage: https://github.com/rubyonjets/omniauth-jets_csrf_protection
98
+ licenses:
99
+ - MIT
100
+ metadata:
101
+ homepage_uri: https://github.com/rubyonjets/omniauth-jets_csrf_protection
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.6.0
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.4.20
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: Provides CSRF protection on OmniAuth request endpoint on Jets application.
121
+ test_files: []