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/sig/omniauth.rbs
ADDED
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
module OmniAuth
|
|
2
|
+
VERSION: String
|
|
3
|
+
|
|
4
|
+
# A Rack environment.
|
|
5
|
+
type env = Rack::env
|
|
6
|
+
|
|
7
|
+
# A Rack response triplet.
|
|
8
|
+
type rack_response = Rack::response
|
|
9
|
+
|
|
10
|
+
# Anything that can be called with a Rack env: a proc, a lambda, or an
|
|
11
|
+
# object or class that responds to #call.
|
|
12
|
+
interface _EnvCallable
|
|
13
|
+
def call: (env) -> untyped
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# A configuration hook. Hooks set to nil or false are skipped.
|
|
17
|
+
type hook = _EnvCallable | false | nil
|
|
18
|
+
|
|
19
|
+
class Error < StandardError
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
class NoSessionError < StandardError
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
class AuthenticityError < StandardError
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
self.@strategies: Array[Class]?
|
|
29
|
+
|
|
30
|
+
def self.strategies: () -> Array[Class]
|
|
31
|
+
|
|
32
|
+
def self.config: () -> Configuration
|
|
33
|
+
|
|
34
|
+
def self.configure: [T] () { (Configuration) -> T } -> T
|
|
35
|
+
|
|
36
|
+
def self.logger: () -> Logger
|
|
37
|
+
|
|
38
|
+
def self.mock_auth_for: (String | Symbol provider) -> (AuthHash | Symbol)
|
|
39
|
+
|
|
40
|
+
class Configuration
|
|
41
|
+
include Singleton
|
|
42
|
+
|
|
43
|
+
def self.instance: () -> Configuration
|
|
44
|
+
|
|
45
|
+
def self.default_logger: () -> Logger
|
|
46
|
+
|
|
47
|
+
self.@defaults: Hash[Symbol, untyped]?
|
|
48
|
+
|
|
49
|
+
def self.defaults: () -> Hash[Symbol, untyped]
|
|
50
|
+
|
|
51
|
+
def initialize: () -> void
|
|
52
|
+
|
|
53
|
+
# Each hook method sets the hook when given a block and returns it
|
|
54
|
+
# otherwise.
|
|
55
|
+
def on_failure: () { (env) -> untyped } -> Proc
|
|
56
|
+
| () -> _EnvCallable
|
|
57
|
+
|
|
58
|
+
def before_callback_phase: () { (env) -> untyped } -> Proc
|
|
59
|
+
| () -> hook
|
|
60
|
+
|
|
61
|
+
def before_options_phase: () { (env) -> untyped } -> Proc
|
|
62
|
+
| () -> hook
|
|
63
|
+
|
|
64
|
+
def request_validation_phase: () { (env) -> untyped } -> Proc
|
|
65
|
+
| () -> hook
|
|
66
|
+
|
|
67
|
+
def before_request_phase: () { (env) -> untyped } -> Proc
|
|
68
|
+
| () -> hook
|
|
69
|
+
|
|
70
|
+
def after_request_phase: () { (env) -> untyped } -> Proc
|
|
71
|
+
| () -> hook
|
|
72
|
+
|
|
73
|
+
def add_mock: (String | Symbol provider, ?Hash[String | Symbol, untyped] original) -> AuthHash
|
|
74
|
+
|
|
75
|
+
def add_camelization: (String | Symbol name, String | Symbol camelized) -> String
|
|
76
|
+
|
|
77
|
+
attr_writer on_failure: _EnvCallable
|
|
78
|
+
attr_writer before_callback_phase: hook
|
|
79
|
+
attr_writer before_options_phase: hook
|
|
80
|
+
attr_writer before_request_phase: hook
|
|
81
|
+
attr_writer after_request_phase: hook
|
|
82
|
+
attr_writer request_validation_phase: hook
|
|
83
|
+
|
|
84
|
+
attr_accessor failure_raise_out_environments: Array[String]
|
|
85
|
+
attr_accessor path_prefix: String
|
|
86
|
+
attr_accessor allowed_request_methods: Array[Symbol]
|
|
87
|
+
attr_accessor form_css: String
|
|
88
|
+
attr_accessor test_mode: bool
|
|
89
|
+
attr_accessor mock_auth: Hash[Symbol, AuthHash | Symbol]
|
|
90
|
+
attr_accessor full_host: String | ^(env) -> String | nil
|
|
91
|
+
attr_accessor camelizations: Hash[String, String]
|
|
92
|
+
attr_accessor logger: Logger
|
|
93
|
+
attr_accessor silence_get_warning: bool
|
|
94
|
+
attr_accessor allowed_hosts: Array[String | Regexp]?
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
module Utils
|
|
98
|
+
def self?.form_css: () -> String
|
|
99
|
+
|
|
100
|
+
def self?.deep_merge: (Hash[untyped, untyped] hash, Hash[untyped, untyped] other_hash) -> Hash[untyped, untyped]
|
|
101
|
+
|
|
102
|
+
def self?.camelize: (String | Symbol word, ?bool first_letter_in_uppercase) -> String
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Generic helper hash that allows method access on deeply nested keys.
|
|
106
|
+
class KeyStore < Hashie::Mash
|
|
107
|
+
def self.override_logging: () -> void
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# The normalized schema returned by all OmniAuth strategies.
|
|
111
|
+
class AuthHash < KeyStore
|
|
112
|
+
def self.subkey_class: () -> singleton(Hashie::Mash)
|
|
113
|
+
|
|
114
|
+
def valid?: () -> bool
|
|
115
|
+
|
|
116
|
+
def regular_writer: (untyped key, untyped value) -> untyped
|
|
117
|
+
|
|
118
|
+
def provider: () -> String?
|
|
119
|
+
def provider?: () -> bool
|
|
120
|
+
def uid: () -> String?
|
|
121
|
+
def uid?: () -> bool
|
|
122
|
+
def info: () -> InfoHash?
|
|
123
|
+
def info?: () -> bool
|
|
124
|
+
def info=: (Hash[untyped, untyped]?) -> Hash[untyped, untyped]?
|
|
125
|
+
def credentials: () -> Hashie::Mash?
|
|
126
|
+
def credentials=: (Hash[untyped, untyped]?) -> Hash[untyped, untyped]?
|
|
127
|
+
def extra: () -> Hashie::Mash?
|
|
128
|
+
def extra=: (Hash[untyped, untyped]?) -> Hash[untyped, untyped]?
|
|
129
|
+
|
|
130
|
+
# The user's information, stored under the `info` key.
|
|
131
|
+
class InfoHash < KeyStore
|
|
132
|
+
def self.subkey_class: () -> singleton(Hashie::Mash)
|
|
133
|
+
|
|
134
|
+
# The name, or a fallback built from first and last name, nickname,
|
|
135
|
+
# or email.
|
|
136
|
+
def name: () -> String?
|
|
137
|
+
def name?: () -> bool
|
|
138
|
+
alias valid? name?
|
|
139
|
+
|
|
140
|
+
def first_name: () -> String?
|
|
141
|
+
def first_name?: () -> bool
|
|
142
|
+
def last_name: () -> String?
|
|
143
|
+
def last_name?: () -> bool
|
|
144
|
+
def nickname: () -> String?
|
|
145
|
+
def nickname?: () -> bool
|
|
146
|
+
def email: () -> String?
|
|
147
|
+
def email?: () -> bool
|
|
148
|
+
|
|
149
|
+
def slice: (*untyped keys) -> self
|
|
150
|
+
def except: (*untyped keys) -> self
|
|
151
|
+
def select: () { (String, untyped) -> boolish } -> self
|
|
152
|
+
def reject: () { (String, untyped) -> boolish } -> self
|
|
153
|
+
|
|
154
|
+
def to_hash: () -> Hash[String, untyped]
|
|
155
|
+
|
|
156
|
+
@subset: bool?
|
|
157
|
+
|
|
158
|
+
private
|
|
159
|
+
|
|
160
|
+
def subset: (self info) -> self
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Raises AuthenticityError unless the request has a valid CSRF token.
|
|
165
|
+
class AuthenticityTokenProtection < Rack::Protection::AuthenticityToken
|
|
166
|
+
def initialize: (?Hash[Symbol, untyped] options) -> void
|
|
167
|
+
|
|
168
|
+
def self.call: (env) -> void
|
|
169
|
+
|
|
170
|
+
def call!: (env) -> void
|
|
171
|
+
|
|
172
|
+
alias call call!
|
|
173
|
+
|
|
174
|
+
private
|
|
175
|
+
|
|
176
|
+
def deny: (env) -> bot
|
|
177
|
+
|
|
178
|
+
alias default_reaction deny
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
class Builder < Rack::Builder
|
|
182
|
+
def on_failure: () { (env) -> untyped } -> Proc
|
|
183
|
+
|
|
184
|
+
def before_options_phase: () { (env) -> untyped } -> Proc
|
|
185
|
+
|
|
186
|
+
def before_request_phase: () { (env) -> untyped } -> Proc
|
|
187
|
+
|
|
188
|
+
def after_request_phase: () { (env) -> untyped } -> Proc
|
|
189
|
+
|
|
190
|
+
def before_callback_phase: () { (env) -> untyped } -> Proc
|
|
191
|
+
|
|
192
|
+
def configure: [T] () { (Configuration) -> T } -> T
|
|
193
|
+
|
|
194
|
+
# Returns the options merged into every provider, or sets them.
|
|
195
|
+
def options: (?false | Hash[Symbol, untyped] options) -> Hash[Symbol, untyped]
|
|
196
|
+
|
|
197
|
+
@options: Hash[Symbol, untyped]?
|
|
198
|
+
|
|
199
|
+
def provider: (Class | String | Symbol klass, *untyped args, **untyped opts) ?{ (*untyped) -> void } -> void
|
|
200
|
+
|
|
201
|
+
def call: (env) -> rack_response
|
|
202
|
+
|
|
203
|
+
@built_app: Rack::_Application?
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# The default `on_failure` endpoint: raises in the configured
|
|
207
|
+
# environments and otherwise redirects to `/auth/failure`.
|
|
208
|
+
class FailureEndpoint
|
|
209
|
+
attr_reader env: env
|
|
210
|
+
|
|
211
|
+
def self.call: (env) -> rack_response
|
|
212
|
+
|
|
213
|
+
def initialize: (env) -> void
|
|
214
|
+
|
|
215
|
+
def call: () -> rack_response
|
|
216
|
+
|
|
217
|
+
def raise_out!: () -> bot
|
|
218
|
+
|
|
219
|
+
def redirect_to_failure: () -> rack_response
|
|
220
|
+
|
|
221
|
+
def strategy_path_prefix: () -> String
|
|
222
|
+
|
|
223
|
+
def strategy_name_query_param: () -> String
|
|
224
|
+
|
|
225
|
+
def origin_query_param: () -> String
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Builds the HTML form some strategies show in their request phase.
|
|
229
|
+
class Form
|
|
230
|
+
DEFAULT_CSS: String
|
|
231
|
+
|
|
232
|
+
attr_accessor options: Hash[Symbol, untyped]
|
|
233
|
+
|
|
234
|
+
def initialize: (?Hash[Symbol, untyped] options) -> void
|
|
235
|
+
|
|
236
|
+
def self.build: (?Hash[Symbol, untyped] options) { (Form) [self: Form] -> void } -> Form
|
|
237
|
+
|
|
238
|
+
def label_field: (String text, String target) -> self
|
|
239
|
+
|
|
240
|
+
def input_field: (String type, String name) -> self
|
|
241
|
+
|
|
242
|
+
def text_field: (String label, String name) -> self
|
|
243
|
+
|
|
244
|
+
def password_field: (String label, String name) -> self
|
|
245
|
+
|
|
246
|
+
def button: (String text) -> String
|
|
247
|
+
|
|
248
|
+
def html: (String html) -> String
|
|
249
|
+
|
|
250
|
+
def fieldset: (String legend, ?Hash[Symbol, untyped] options) { (Form) [self: Form] -> void } -> self
|
|
251
|
+
|
|
252
|
+
def header: (String title, String header_info) -> self
|
|
253
|
+
|
|
254
|
+
def footer: () -> self
|
|
255
|
+
|
|
256
|
+
def to_html: () -> String
|
|
257
|
+
|
|
258
|
+
def to_response: () -> rack_response
|
|
259
|
+
|
|
260
|
+
@html: String
|
|
261
|
+
@with_custom_button: bool
|
|
262
|
+
@footer: bool?
|
|
263
|
+
|
|
264
|
+
private
|
|
265
|
+
|
|
266
|
+
def css: () -> String
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# The mixin every OmniAuth strategy includes.
|
|
270
|
+
module Strategy
|
|
271
|
+
include Fetchers
|
|
272
|
+
include Hosts
|
|
273
|
+
include Paths
|
|
274
|
+
include SignIns
|
|
275
|
+
include TestMode
|
|
276
|
+
|
|
277
|
+
def self.included: (Class & ClassMethods base) -> void
|
|
278
|
+
|
|
279
|
+
# Strategy extends the class that includes it with ClassMethods.
|
|
280
|
+
def class: () -> ClassMethods
|
|
281
|
+
|
|
282
|
+
def dup: () -> self
|
|
283
|
+
|
|
284
|
+
# The parts of Strategy that Fetchers, Paths, and TestMode rely on.
|
|
285
|
+
interface _Core
|
|
286
|
+
def class: () -> ClassMethods
|
|
287
|
+
def options: () -> Options
|
|
288
|
+
def env: () -> env
|
|
289
|
+
def request: () -> Rack::Request
|
|
290
|
+
def session: () -> Hash[String, untyped]
|
|
291
|
+
def name: () -> String
|
|
292
|
+
def log: (Symbol level, String message) -> void
|
|
293
|
+
def setup_phase: () -> void
|
|
294
|
+
def call_app!: (?env env) -> rack_response
|
|
295
|
+
def redirect: (String uri) -> rack_response
|
|
296
|
+
def fail!: (String | Symbol message_key, ?Exception? exception) -> rack_response
|
|
297
|
+
def store_origin: () -> void
|
|
298
|
+
def omniauth_params: () -> Hash[String, untyped]
|
|
299
|
+
def request_call?: () -> boolish
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
module ClassMethods
|
|
303
|
+
@default_options: Options?
|
|
304
|
+
@args: Array[Symbol]?
|
|
305
|
+
@default_dispatch: bool
|
|
306
|
+
|
|
307
|
+
DISPATCH_METHODS: Array[Symbol]
|
|
308
|
+
|
|
309
|
+
def default_dispatch?: () -> bool
|
|
310
|
+
|
|
311
|
+
def default_options: () -> Options
|
|
312
|
+
|
|
313
|
+
def configure: (?Hash[Symbol, untyped]? options) ?{ (Options) -> void } -> untyped
|
|
314
|
+
|
|
315
|
+
def option: (Symbol | String name, ?untyped value) -> untyped
|
|
316
|
+
|
|
317
|
+
def args: () -> Array[Symbol]
|
|
318
|
+
| (Array[Symbol] | Symbol args) -> nil
|
|
319
|
+
|
|
320
|
+
# The fetcher blocks run with the strategy instance as self.
|
|
321
|
+
def uid: () { () [self: Strategy] -> untyped } -> Proc
|
|
322
|
+
| () -> Proc?
|
|
323
|
+
|
|
324
|
+
def info: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
|
|
325
|
+
| () -> Proc?
|
|
326
|
+
|
|
327
|
+
def extra: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
|
|
328
|
+
| () -> Proc?
|
|
329
|
+
|
|
330
|
+
def credentials: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
|
|
331
|
+
| () -> Proc?
|
|
332
|
+
|
|
333
|
+
def uid_stack: (untyped context) -> Array[untyped]
|
|
334
|
+
def info_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
|
335
|
+
def extra_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
|
336
|
+
def credentials_stack: (untyped context) -> Array[Hash[untyped, untyped]]
|
|
337
|
+
|
|
338
|
+
def compile_stack: (Array[Module] ancestors, Symbol method, untyped context) -> Array[untyped]
|
|
339
|
+
|
|
340
|
+
# Defined by Module, which every strategy class is.
|
|
341
|
+
def ancestors: () -> Array[Module]
|
|
342
|
+
def superclass: () -> Class?
|
|
343
|
+
def name: () -> String?
|
|
344
|
+
def class_eval: (String code, ?String file, ?Integer line) -> untyped
|
|
345
|
+
def instance_method: (Symbol name) -> UnboundMethod
|
|
346
|
+
|
|
347
|
+
# Defined by Class.
|
|
348
|
+
def allocate: () -> Strategy
|
|
349
|
+
|
|
350
|
+
private
|
|
351
|
+
|
|
352
|
+
attr_reader uid_proc: Proc?
|
|
353
|
+
attr_reader info_proc: Proc?
|
|
354
|
+
attr_reader extra_proc: Proc?
|
|
355
|
+
attr_reader credentials_proc: Proc?
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
# Options for a strategy instance: the class's default options merged
|
|
359
|
+
# with the ones passed to the strategy.
|
|
360
|
+
class Options < KeyStore
|
|
361
|
+
# Options OmniAuth reads itself. Strategies add their own.
|
|
362
|
+
def name: () -> String
|
|
363
|
+
def log: (Symbol level, String message) -> void
|
|
364
|
+
# false, true (render the app's own form), or a Rack endpoint
|
|
365
|
+
def form: () -> untyped
|
|
366
|
+
def origin_param: () -> (String | false)
|
|
367
|
+
# A boolean, or something callable that takes the uid
|
|
368
|
+
def skip_info: () -> untyped
|
|
369
|
+
def skip_info?: () -> bool
|
|
370
|
+
def fields: () -> Array[Symbol]
|
|
371
|
+
def uid_field: () -> Symbol
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
# Builds the auth hash from the uid, info, credentials, and extra
|
|
375
|
+
# blocks a strategy declares with the class-level fetcher DSL.
|
|
376
|
+
module Fetchers : _Core
|
|
377
|
+
def uid: () -> untyped
|
|
378
|
+
|
|
379
|
+
def info: () -> Hash[untyped, untyped]
|
|
380
|
+
|
|
381
|
+
def credentials: () -> Hash[untyped, untyped]
|
|
382
|
+
|
|
383
|
+
def extra: () -> Hash[untyped, untyped]
|
|
384
|
+
|
|
385
|
+
def auth_hash: () -> AuthHash
|
|
386
|
+
|
|
387
|
+
def skip_info?: () -> boolish
|
|
388
|
+
|
|
389
|
+
private
|
|
390
|
+
|
|
391
|
+
def merge_stack: (Array[Hash[untyped, untyped]] stack) -> Hash[untyped, untyped]
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
# Works out the request, callback, and setup paths for a strategy and
|
|
395
|
+
# whether the current request is on one of them, plus the full URLs
|
|
396
|
+
# built from them.
|
|
397
|
+
module Paths : _Core
|
|
398
|
+
CURRENT_PATH_REGEX: Regexp
|
|
399
|
+
FORMAT_EXTENSION_REGEX: Regexp
|
|
400
|
+
EMPTY_STRING: String
|
|
401
|
+
SSL_ENV_VALUES: Hash[String, String]
|
|
402
|
+
|
|
403
|
+
def on_auth_path?: () -> boolish
|
|
404
|
+
|
|
405
|
+
def on_request_path?: () -> boolish
|
|
406
|
+
|
|
407
|
+
def on_callback_path?: () -> bool
|
|
408
|
+
|
|
409
|
+
def on_path?: (String path) -> bool
|
|
410
|
+
|
|
411
|
+
def path_prefix: () -> String
|
|
412
|
+
|
|
413
|
+
def custom_path: (Symbol kind) -> String?
|
|
414
|
+
|
|
415
|
+
def request_path: () -> String
|
|
416
|
+
|
|
417
|
+
def callback_path: () -> String
|
|
418
|
+
|
|
419
|
+
def setup_path: () -> String
|
|
420
|
+
|
|
421
|
+
def current_path: () -> String
|
|
422
|
+
|
|
423
|
+
def query_string: () -> String
|
|
424
|
+
|
|
425
|
+
def full_host: () -> String
|
|
426
|
+
|
|
427
|
+
def callback_url: () -> String
|
|
428
|
+
|
|
429
|
+
def script_name: () -> String
|
|
430
|
+
|
|
431
|
+
@env: env?
|
|
432
|
+
@request_path: String?
|
|
433
|
+
@callback_path: String?
|
|
434
|
+
@current_path: String?
|
|
435
|
+
|
|
436
|
+
private
|
|
437
|
+
|
|
438
|
+
def callback_path_option: () -> String?
|
|
439
|
+
|
|
440
|
+
def full_host_from_request: () -> String
|
|
441
|
+
|
|
442
|
+
def ssl?: () -> bool
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
# Guards against forged hosts in callback URLs.
|
|
446
|
+
module Hosts : _Core, Paths
|
|
447
|
+
private
|
|
448
|
+
|
|
449
|
+
def allowed_host?: () -> bool
|
|
450
|
+
|
|
451
|
+
def full_host_set?: () -> bool
|
|
452
|
+
|
|
453
|
+
def warn_if_using_request_host: () -> void
|
|
454
|
+
|
|
455
|
+
def invalid_host!: () -> rack_response
|
|
456
|
+
end
|
|
457
|
+
|
|
458
|
+
# Keeps the origin and params of several sign-ins in progress at once.
|
|
459
|
+
# A strategy opts in by calling remember_sign_in in its request phase
|
|
460
|
+
# and overriding callback_sign_in_key.
|
|
461
|
+
module SignIns : _Core
|
|
462
|
+
MAX_REMEMBERED_SIGN_INS: Integer
|
|
463
|
+
|
|
464
|
+
# Remembers the current request phase's origin and params under key,
|
|
465
|
+
# which the provider sends back to the callback.
|
|
466
|
+
def remember_sign_in: (String key) -> void
|
|
467
|
+
|
|
468
|
+
# The key the callback sends back, or nil for a strategy that doesn't
|
|
469
|
+
# remember sign-ins.
|
|
470
|
+
def callback_sign_in_key: () -> String?
|
|
471
|
+
|
|
472
|
+
private
|
|
473
|
+
|
|
474
|
+
# The "origin" and "params" for this callback, removed from the
|
|
475
|
+
# session.
|
|
476
|
+
def recall_sign_in: () -> Hash[String, untyped]
|
|
477
|
+
|
|
478
|
+
def remembered_sign_ins: () -> Hash[String, Hash[String, untyped]]
|
|
479
|
+
end
|
|
480
|
+
|
|
481
|
+
# Runs the request and callback phases against OmniAuth.config.mock_auth
|
|
482
|
+
# instead of the provider when OmniAuth.config.test_mode is enabled.
|
|
483
|
+
module TestMode : _Core, Paths
|
|
484
|
+
def mock_call!: (*untyped) -> rack_response
|
|
485
|
+
|
|
486
|
+
def mock_request_call: () -> rack_response
|
|
487
|
+
|
|
488
|
+
def mock_callback_call: () -> rack_response
|
|
489
|
+
|
|
490
|
+
private
|
|
491
|
+
|
|
492
|
+
# Defined in Strategy.
|
|
493
|
+
def handle_phase_error: (StandardError error) -> rack_response
|
|
494
|
+
def run_hook: (Symbol name) -> void
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
attr_reader app: Rack::_Application
|
|
498
|
+
attr_reader env (): env
|
|
499
|
+
attr_reader options: Options
|
|
500
|
+
attr_reader response: untyped
|
|
501
|
+
|
|
502
|
+
def initialize: (Rack::_Application app, *untyped args) ?{ (Options) -> void } -> void
|
|
503
|
+
|
|
504
|
+
# Called with the Rack env; nil until then.
|
|
505
|
+
@env: env?
|
|
506
|
+
|
|
507
|
+
def inspect: () -> String
|
|
508
|
+
|
|
509
|
+
def log: (Symbol level, String message) -> void
|
|
510
|
+
|
|
511
|
+
def call: (env) -> rack_response
|
|
512
|
+
|
|
513
|
+
def call!: (env) -> rack_response
|
|
514
|
+
|
|
515
|
+
def phase_call: () -> rack_response?
|
|
516
|
+
|
|
517
|
+
def options_call?: () -> boolish
|
|
518
|
+
|
|
519
|
+
def request_call?: () -> boolish
|
|
520
|
+
|
|
521
|
+
def warn_if_using_get_on_request_path: () -> void
|
|
522
|
+
|
|
523
|
+
def options_call: () -> rack_response
|
|
524
|
+
|
|
525
|
+
def request_call: () -> rack_response
|
|
526
|
+
|
|
527
|
+
def request_response: () -> rack_response
|
|
528
|
+
|
|
529
|
+
AUTHENTICITY_PARAM: String
|
|
530
|
+
|
|
531
|
+
# The request phase's query and form params, minus the authenticity
|
|
532
|
+
# token, which the callback phase hands back as `omniauth.params`.
|
|
533
|
+
def omniauth_params: () -> Hash[String, untyped]
|
|
534
|
+
|
|
535
|
+
def store_origin: () -> void
|
|
536
|
+
|
|
537
|
+
def callback_call: () -> rack_response
|
|
538
|
+
|
|
539
|
+
def options_request?: () -> bool
|
|
540
|
+
|
|
541
|
+
# Optional. A strategy can define this to handle requests to paths
|
|
542
|
+
# other than its request and callback paths.
|
|
543
|
+
def other_phase: () -> rack_response
|
|
544
|
+
|
|
545
|
+
def setup_phase: () -> void
|
|
546
|
+
|
|
547
|
+
def request_phase: () -> rack_response
|
|
548
|
+
|
|
549
|
+
def callback_phase: () -> rack_response
|
|
550
|
+
|
|
551
|
+
def call_app!: (?env env) -> rack_response
|
|
552
|
+
|
|
553
|
+
def session: () -> Hash[String, untyped]
|
|
554
|
+
|
|
555
|
+
def request: () -> Rack::Request
|
|
556
|
+
|
|
557
|
+
def name: () -> String
|
|
558
|
+
|
|
559
|
+
def redirect: (String uri) -> rack_response
|
|
560
|
+
|
|
561
|
+
def user_info: () -> Hash[untyped, untyped]
|
|
562
|
+
|
|
563
|
+
def fail!: (String | Symbol message_key, ?Exception? exception) -> rack_response
|
|
564
|
+
|
|
565
|
+
@app: Rack::_Application
|
|
566
|
+
@options: Options
|
|
567
|
+
@request: Rack::Request?
|
|
568
|
+
|
|
569
|
+
private
|
|
570
|
+
|
|
571
|
+
def handle_phase_error: (StandardError error) -> rack_response
|
|
572
|
+
|
|
573
|
+
def run_hook: (Symbol name) -> void
|
|
574
|
+
|
|
575
|
+
def initialize_copy: (*untyped) -> void
|
|
576
|
+
|
|
577
|
+
def passthrough?: (env env) -> bool
|
|
578
|
+
|
|
579
|
+
def dispatch_by_path?: () -> bool
|
|
580
|
+
|
|
581
|
+
def path_probe: (env env) -> Strategy
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
module Strategies
|
|
585
|
+
# A strategy for development that asks for a name and email.
|
|
586
|
+
class Developer
|
|
587
|
+
include Strategy
|
|
588
|
+
extend Strategy::ClassMethods
|
|
589
|
+
|
|
590
|
+
def request_phase: () -> rack_response
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
module Test
|
|
595
|
+
# A Rack middleware that keeps one session hash across requests.
|
|
596
|
+
class PhonySession
|
|
597
|
+
def initialize: (Rack::_Application app) -> void
|
|
598
|
+
|
|
599
|
+
def call: (env) -> rack_response
|
|
600
|
+
|
|
601
|
+
@app: Rack::_Application
|
|
602
|
+
@session: Hash[String, untyped]?
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
# RSpec macros for strategy specs, for example:
|
|
606
|
+
#
|
|
607
|
+
# describe MyStrategy, type: :strategy do
|
|
608
|
+
# sets_an_auth_hash
|
|
609
|
+
# end
|
|
610
|
+
module StrategyMacros : _ExampleGroup
|
|
611
|
+
interface _ExampleGroup
|
|
612
|
+
def it: (String description) { () [self: _Example] -> void } -> void
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
# What the examples these macros define rely on: RSpec expectations
|
|
616
|
+
# and Rack::Test's last_request.
|
|
617
|
+
interface _Example
|
|
618
|
+
def expect: (untyped actual) -> untyped
|
|
619
|
+
def eq: (untyped expected) -> untyped
|
|
620
|
+
def be_kind_of: (Module expected) -> untyped
|
|
621
|
+
def last_request: () -> Rack::Request
|
|
622
|
+
end
|
|
623
|
+
|
|
624
|
+
def sets_an_auth_hash: () -> void
|
|
625
|
+
|
|
626
|
+
def sets_provider_to: (String provider) -> void
|
|
627
|
+
|
|
628
|
+
def sets_uid_to: (String uid) -> void
|
|
629
|
+
|
|
630
|
+
def sets_user_info_to: (Hash[untyped, untyped] user_info) -> void
|
|
631
|
+
end
|
|
632
|
+
|
|
633
|
+
# A test case helper that builds a Rack app around the strategy under
|
|
634
|
+
# test. The including test case must define #strategy and use
|
|
635
|
+
# Rack::Test.
|
|
636
|
+
module StrategyTestCase : _RackTest
|
|
637
|
+
interface _RackTest
|
|
638
|
+
def last_request: () -> Rack::Request
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
def app: () -> Rack::_Application
|
|
642
|
+
|
|
643
|
+
def app_response: () -> untyped
|
|
644
|
+
|
|
645
|
+
def session: () -> Hash[String, untyped]
|
|
646
|
+
|
|
647
|
+
def strategy: () -> Array[untyped]
|
|
648
|
+
end
|
|
649
|
+
end
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
# rack-protection doesn't ship types, so declare the classes OmniAuth's
|
|
653
|
+
# signatures build on.
|
|
654
|
+
module Rack
|
|
655
|
+
module Protection
|
|
656
|
+
class Base
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
class AuthenticityToken < Base
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
end
|