omniauth 2.1.4 → 2.3.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/LICENSE.md +1 -1
- data/README.md +170 -29
- data/SECURITY.md +5 -3
- data/lib/omniauth/auth_hash.rb +32 -6
- data/lib/omniauth/authenticity_token_protection.rb +6 -4
- data/lib/omniauth/builder.rb +9 -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/sign_ins.rb +57 -0
- data/lib/omniauth/strategy/test_mode.rb +53 -0
- data/lib/omniauth/strategy.rb +149 -361
- 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 +28 -25
- data/sig/manifest.yaml +5 -0
- data/sig/omniauth.rbs +662 -0
- metadata +30 -59
- 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 -24
- data/Rakefile +0 -53
- data/omniauth.gemspec +0 -26
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,18 +25,18 @@ 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,
|
|
45
41
|
:after_request_phase => nil,
|
|
46
42
|
:before_callback_phase => nil,
|
|
@@ -50,12 +46,13 @@ module OmniAuth
|
|
|
50
46
|
:logger => default_logger,
|
|
51
47
|
:allowed_request_methods => %i[post],
|
|
52
48
|
:mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})},
|
|
53
|
-
:silence_get_warning => false
|
|
49
|
+
:silence_get_warning => false,
|
|
50
|
+
:allowed_hosts => nil
|
|
54
51
|
}
|
|
55
52
|
end
|
|
56
53
|
|
|
57
54
|
def initialize
|
|
58
|
-
self.class.defaults.each_pair { |k, v|
|
|
55
|
+
self.class.defaults.each_pair { |k, v| public_send("#{k}=", v) }
|
|
59
56
|
end
|
|
60
57
|
|
|
61
58
|
def on_failure(&block)
|
|
@@ -108,17 +105,18 @@ module OmniAuth
|
|
|
108
105
|
|
|
109
106
|
def add_mock(provider, original = {})
|
|
110
107
|
# Create key-stringified new hash from given auth hash
|
|
111
|
-
mock = {}
|
|
108
|
+
mock = {} #: Hash[String, untyped]
|
|
112
109
|
original.each_pair do |key, val|
|
|
113
110
|
mock[key.to_s] = if val.is_a? Hash
|
|
114
|
-
|
|
111
|
+
val.transform_keys(&:to_s)
|
|
115
112
|
else
|
|
116
113
|
val
|
|
117
114
|
end
|
|
118
115
|
end
|
|
119
116
|
|
|
120
117
|
# Merge with the default mock and ensure provider is correct.
|
|
121
|
-
|
|
118
|
+
default = mock_auth.fetch(:default) #: AuthHash
|
|
119
|
+
mock = default.merge(mock)
|
|
122
120
|
mock['provider'] = provider.to_s
|
|
123
121
|
|
|
124
122
|
# Add it to the mocks.
|
|
@@ -137,7 +135,8 @@ module OmniAuth
|
|
|
137
135
|
|
|
138
136
|
attr_writer :on_failure, :before_callback_phase, :before_options_phase, :before_request_phase, :after_request_phase, :request_validation_phase
|
|
139
137
|
attr_accessor :failure_raise_out_environments, :path_prefix, :allowed_request_methods, :form_css,
|
|
140
|
-
: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
|
|
141
140
|
end
|
|
142
141
|
|
|
143
142
|
def self.config
|
|
@@ -157,7 +156,7 @@ module OmniAuth
|
|
|
157
156
|
end
|
|
158
157
|
|
|
159
158
|
module Utils
|
|
160
|
-
module_function
|
|
159
|
+
module_function
|
|
161
160
|
|
|
162
161
|
def form_css
|
|
163
162
|
"<style type='text/css'>#{OmniAuth.config.form_css}</style>"
|
|
@@ -166,25 +165,29 @@ module OmniAuth
|
|
|
166
165
|
def deep_merge(hash, other_hash)
|
|
167
166
|
target = hash.dup
|
|
168
167
|
|
|
169
|
-
other_hash.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
next
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
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
|
|
176
171
|
end
|
|
177
172
|
|
|
178
173
|
target
|
|
179
174
|
end
|
|
180
175
|
|
|
181
176
|
def camelize(word, first_letter_in_uppercase = true)
|
|
182
|
-
|
|
177
|
+
camelized = OmniAuth.config.camelizations[word.to_s]
|
|
178
|
+
return camelized if camelized
|
|
183
179
|
|
|
184
180
|
if first_letter_in_uppercase
|
|
185
|
-
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
|
|
186
189
|
else
|
|
187
|
-
camelize(word).tap { |w| w[0] = w[0].downcase }
|
|
190
|
+
camelize(word).tap { |w| w[0] = w[0].to_s.downcase }
|
|
188
191
|
end
|
|
189
192
|
end
|
|
190
193
|
end
|