omniauth 2.1.3 → 2.2.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 +4 -4
- data/CHANGELOG.md +726 -0
- data/LICENSE.md +1 -1
- data/README.md +141 -29
- data/SECURITY.md +4 -3
- data/lib/omniauth/auth_hash.rb +32 -6
- data/lib/omniauth/authenticity_token_protection.rb +6 -4
- data/lib/omniauth/builder.rb +13 -6
- data/lib/omniauth/failure_endpoint.rb +4 -4
- data/lib/omniauth/form.rb +5 -7
- data/lib/omniauth/key_store.rb +2 -10
- data/lib/omniauth/strategies/developer.rb +3 -5
- data/lib/omniauth/strategy/class_methods.rb +118 -0
- data/lib/omniauth/strategy/fetchers.rb +57 -0
- data/lib/omniauth/strategy/hosts.rb +48 -0
- data/lib/omniauth/strategy/paths.rb +140 -0
- data/lib/omniauth/strategy/test_mode.rb +53 -0
- data/lib/omniauth/strategy.rb +145 -354
- data/lib/omniauth/test/phony_session.rb +1 -1
- data/lib/omniauth/test/strategy_test_case.rb +8 -9
- data/lib/omniauth/version.rb +1 -1
- data/lib/omniauth.rb +38 -26
- data/sig/manifest.yaml +5 -0
- data/sig/omniauth.rbs +638 -0
- metadata +33 -51
- data/.github/FUNDING.yml +0 -2
- data/.github/ISSUE_TEMPLATE.md +0 -20
- data/.github/dependabot.yml +0 -18
- data/.github/workflows/jruby.yml +0 -28
- data/.github/workflows/main.yml +0 -64
- data/.github/workflows/truffle_ruby.yml +0 -24
- data/.gitignore +0 -14
- data/.rspec +0 -2
- data/.rubocop.yml +0 -69
- data/.yardopts +0 -4
- data/Gemfile +0 -23
- data/Rakefile +0 -53
- data/omniauth.gemspec +0 -25
data/lib/omniauth.rb
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
# TODO: Fixed in https://github.com/rack/rack/pull/1610 for Rack 3
|
|
2
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
|
3
|
-
require 'delegate'
|
|
4
|
-
end
|
|
5
1
|
require 'rack'
|
|
6
2
|
require 'singleton'
|
|
7
3
|
require 'logger'
|
|
@@ -29,19 +25,20 @@ module OmniAuth
|
|
|
29
25
|
include Singleton
|
|
30
26
|
|
|
31
27
|
def self.default_logger
|
|
32
|
-
logger = Logger.new(
|
|
28
|
+
logger = Logger.new($stdout)
|
|
33
29
|
logger.progname = 'omniauth'
|
|
34
30
|
logger
|
|
35
31
|
end
|
|
36
32
|
|
|
37
|
-
def self.defaults # rubocop:disable MethodLength
|
|
33
|
+
def self.defaults # rubocop:disable Metrics/MethodLength
|
|
38
34
|
@defaults ||= {
|
|
39
35
|
:camelizations => {},
|
|
40
36
|
:path_prefix => '/auth',
|
|
41
|
-
:on_failure =>
|
|
37
|
+
:on_failure => FailureEndpoint,
|
|
42
38
|
:failure_raise_out_environments => ['development'],
|
|
43
|
-
:request_validation_phase =>
|
|
39
|
+
:request_validation_phase => AuthenticityTokenProtection,
|
|
44
40
|
:before_request_phase => nil,
|
|
41
|
+
:after_request_phase => nil,
|
|
45
42
|
:before_callback_phase => nil,
|
|
46
43
|
:before_options_phase => nil,
|
|
47
44
|
:form_css => Form::DEFAULT_CSS,
|
|
@@ -49,12 +46,13 @@ module OmniAuth
|
|
|
49
46
|
:logger => default_logger,
|
|
50
47
|
:allowed_request_methods => %i[post],
|
|
51
48
|
:mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})},
|
|
52
|
-
:silence_get_warning => false
|
|
49
|
+
:silence_get_warning => false,
|
|
50
|
+
:allowed_hosts => nil
|
|
53
51
|
}
|
|
54
52
|
end
|
|
55
53
|
|
|
56
54
|
def initialize
|
|
57
|
-
self.class.defaults.each_pair { |k, v|
|
|
55
|
+
self.class.defaults.each_pair { |k, v| public_send("#{k}=", v) }
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def on_failure(&block)
|
|
@@ -97,19 +95,28 @@ module OmniAuth
|
|
|
97
95
|
end
|
|
98
96
|
end
|
|
99
97
|
|
|
98
|
+
def after_request_phase(&block)
|
|
99
|
+
if block_given?
|
|
100
|
+
@after_request_phase = block
|
|
101
|
+
else
|
|
102
|
+
@after_request_phase
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
100
106
|
def add_mock(provider, original = {})
|
|
101
107
|
# Create key-stringified new hash from given auth hash
|
|
102
|
-
mock = {}
|
|
108
|
+
mock = {} #: Hash[String, untyped]
|
|
103
109
|
original.each_pair do |key, val|
|
|
104
110
|
mock[key.to_s] = if val.is_a? Hash
|
|
105
|
-
|
|
111
|
+
val.transform_keys(&:to_s)
|
|
106
112
|
else
|
|
107
113
|
val
|
|
108
114
|
end
|
|
109
115
|
end
|
|
110
116
|
|
|
111
117
|
# Merge with the default mock and ensure provider is correct.
|
|
112
|
-
|
|
118
|
+
default = mock_auth.fetch(:default) #: AuthHash
|
|
119
|
+
mock = default.merge(mock)
|
|
113
120
|
mock['provider'] = provider.to_s
|
|
114
121
|
|
|
115
122
|
# Add it to the mocks.
|
|
@@ -126,9 +133,10 @@ module OmniAuth
|
|
|
126
133
|
camelizations[name.to_s] = camelized.to_s
|
|
127
134
|
end
|
|
128
135
|
|
|
129
|
-
attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :request_validation_phase
|
|
136
|
+
attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :after_request_phase, :request_validation_phase
|
|
130
137
|
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css,
|
|
131
|
-
:test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning
|
|
138
|
+
:test_mode, :mock_auth, :full_host, :camelizations, :logger, :silence_get_warning,
|
|
139
|
+
:allowed_hosts
|
|
132
140
|
end
|
|
133
141
|
|
|
134
142
|
def self.config
|
|
@@ -148,7 +156,7 @@ module OmniAuth
|
|
|
148
156
|
end
|
|
149
157
|
|
|
150
158
|
module Utils
|
|
151
|
-
module_function
|
|
159
|
+
module_function
|
|
152
160
|
|
|
153
161
|
def form_css
|
|
154
162
|
"<style type='text/css'>#{OmniAuth.config.form_css}</style>"
|
|
@@ -157,25 +165,29 @@ module OmniAuth
|
|
|
157
165
|
def deep_merge(hash, other_hash)
|
|
158
166
|
target = hash.dup
|
|
159
167
|
|
|
160
|
-
other_hash.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
next
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
target[key] = other_hash[key]
|
|
168
|
+
other_hash.each_pair do |key, value|
|
|
169
|
+
current = hash[key]
|
|
170
|
+
target[key] = current.is_a?(Hash) && value.is_a?(Hash) ? deep_merge(current, value) : value
|
|
167
171
|
end
|
|
168
172
|
|
|
169
173
|
target
|
|
170
174
|
end
|
|
171
175
|
|
|
172
176
|
def camelize(word, first_letter_in_uppercase = true)
|
|
173
|
-
|
|
177
|
+
camelized = OmniAuth.config.camelizations[word.to_s]
|
|
178
|
+
return camelized if camelized
|
|
174
179
|
|
|
175
180
|
if first_letter_in_uppercase
|
|
176
|
-
word.to_s.gsub(%r{/(.?)})
|
|
181
|
+
namespaced = word.to_s.gsub(%r{/(.?)}) do
|
|
182
|
+
char = Regexp.last_match(1) #: String
|
|
183
|
+
"::#{char.upcase}"
|
|
184
|
+
end
|
|
185
|
+
namespaced.gsub(/(\A|_)(.)/) do
|
|
186
|
+
char = Regexp.last_match(2) #: String
|
|
187
|
+
char.upcase
|
|
188
|
+
end
|
|
177
189
|
else
|
|
178
|
-
camelize(word).tap { |w| w[0] = w[0].downcase }
|
|
190
|
+
camelize(word).tap { |w| w[0] = w[0].to_s.downcase }
|
|
179
191
|
end
|
|
180
192
|
end
|
|
181
193
|
end
|