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.
data/sig/omniauth.rbs ADDED
@@ -0,0 +1,638 @@
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 TestMode
275
+
276
+ def self.included: (Class & ClassMethods base) -> void
277
+
278
+ # Strategy extends the class that includes it with ClassMethods.
279
+ def class: () -> ClassMethods
280
+
281
+ def dup: () -> self
282
+
283
+ # The parts of Strategy that Fetchers, Paths, and TestMode rely on.
284
+ interface _Core
285
+ def class: () -> ClassMethods
286
+ def options: () -> Options
287
+ def env: () -> env
288
+ def request: () -> Rack::Request
289
+ def session: () -> Hash[String, untyped]
290
+ def name: () -> String
291
+ def log: (Symbol level, String message) -> void
292
+ def setup_phase: () -> void
293
+ def call_app!: (?env env) -> rack_response
294
+ def redirect: (String uri) -> rack_response
295
+ def fail!: (String | Symbol message_key, ?Exception? exception) -> rack_response
296
+ def store_origin: () -> void
297
+ def omniauth_params: () -> Hash[String, untyped]
298
+ def request_call?: () -> boolish
299
+ end
300
+
301
+ module ClassMethods
302
+ @default_options: Options?
303
+ @args: Array[Symbol]?
304
+ @default_dispatch: bool
305
+
306
+ DISPATCH_METHODS: Array[Symbol]
307
+
308
+ def default_dispatch?: () -> bool
309
+
310
+ def default_options: () -> Options
311
+
312
+ def configure: (?Hash[Symbol, untyped]? options) ?{ (Options) -> void } -> untyped
313
+
314
+ def option: (Symbol | String name, ?untyped value) -> untyped
315
+
316
+ def args: () -> Array[Symbol]
317
+ | (Array[Symbol] | Symbol args) -> nil
318
+
319
+ # The fetcher blocks run with the strategy instance as self.
320
+ def uid: () { () [self: Strategy] -> untyped } -> Proc
321
+ | () -> Proc?
322
+
323
+ def info: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
324
+ | () -> Proc?
325
+
326
+ def extra: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
327
+ | () -> Proc?
328
+
329
+ def credentials: () { () [self: Strategy] -> Hash[untyped, untyped]? } -> Proc
330
+ | () -> Proc?
331
+
332
+ def uid_stack: (untyped context) -> Array[untyped]
333
+ def info_stack: (untyped context) -> Array[Hash[untyped, untyped]]
334
+ def extra_stack: (untyped context) -> Array[Hash[untyped, untyped]]
335
+ def credentials_stack: (untyped context) -> Array[Hash[untyped, untyped]]
336
+
337
+ def compile_stack: (Array[Module] ancestors, Symbol method, untyped context) -> Array[untyped]
338
+
339
+ # Defined by Module, which every strategy class is.
340
+ def ancestors: () -> Array[Module]
341
+ def superclass: () -> Class?
342
+ def name: () -> String?
343
+ def class_eval: (String code, ?String file, ?Integer line) -> untyped
344
+ def instance_method: (Symbol name) -> UnboundMethod
345
+
346
+ # Defined by Class.
347
+ def allocate: () -> Strategy
348
+
349
+ private
350
+
351
+ attr_reader uid_proc: Proc?
352
+ attr_reader info_proc: Proc?
353
+ attr_reader extra_proc: Proc?
354
+ attr_reader credentials_proc: Proc?
355
+ end
356
+
357
+ # Options for a strategy instance: the class's default options merged
358
+ # with the ones passed to the strategy.
359
+ class Options < KeyStore
360
+ # Options OmniAuth reads itself. Strategies add their own.
361
+ def name: () -> String
362
+ def log: (Symbol level, String message) -> void
363
+ # false, true (render the app's own form), or a Rack endpoint
364
+ def form: () -> untyped
365
+ def origin_param: () -> (String | false)
366
+ # A boolean, or something callable that takes the uid
367
+ def skip_info: () -> untyped
368
+ def skip_info?: () -> bool
369
+ def fields: () -> Array[Symbol]
370
+ def uid_field: () -> Symbol
371
+ end
372
+
373
+ # Builds the auth hash from the uid, info, credentials, and extra
374
+ # blocks a strategy declares with the class-level fetcher DSL.
375
+ module Fetchers : _Core
376
+ def uid: () -> untyped
377
+
378
+ def info: () -> Hash[untyped, untyped]
379
+
380
+ def credentials: () -> Hash[untyped, untyped]
381
+
382
+ def extra: () -> Hash[untyped, untyped]
383
+
384
+ def auth_hash: () -> AuthHash
385
+
386
+ def skip_info?: () -> boolish
387
+
388
+ private
389
+
390
+ def merge_stack: (Array[Hash[untyped, untyped]] stack) -> Hash[untyped, untyped]
391
+ end
392
+
393
+ # Works out the request, callback, and setup paths for a strategy and
394
+ # whether the current request is on one of them, plus the full URLs
395
+ # built from them.
396
+ module Paths : _Core
397
+ CURRENT_PATH_REGEX: Regexp
398
+ FORMAT_EXTENSION_REGEX: Regexp
399
+ EMPTY_STRING: String
400
+ SSL_ENV_VALUES: Hash[String, String]
401
+
402
+ def on_auth_path?: () -> boolish
403
+
404
+ def on_request_path?: () -> boolish
405
+
406
+ def on_callback_path?: () -> bool
407
+
408
+ def on_path?: (String path) -> bool
409
+
410
+ def path_prefix: () -> String
411
+
412
+ def custom_path: (Symbol kind) -> String?
413
+
414
+ def request_path: () -> String
415
+
416
+ def callback_path: () -> String
417
+
418
+ def setup_path: () -> String
419
+
420
+ def current_path: () -> String
421
+
422
+ def query_string: () -> String
423
+
424
+ def full_host: () -> String
425
+
426
+ def callback_url: () -> String
427
+
428
+ def script_name: () -> String
429
+
430
+ @env: env?
431
+ @request_path: String?
432
+ @callback_path: String?
433
+ @current_path: String?
434
+
435
+ private
436
+
437
+ def callback_path_option: () -> String?
438
+
439
+ def full_host_from_request: () -> String
440
+
441
+ def ssl?: () -> bool
442
+ end
443
+
444
+ # Guards against forged hosts in callback URLs.
445
+ module Hosts : _Core, Paths
446
+ private
447
+
448
+ def allowed_host?: () -> bool
449
+
450
+ def full_host_set?: () -> bool
451
+
452
+ def warn_if_using_request_host: () -> void
453
+
454
+ def invalid_host!: () -> rack_response
455
+ end
456
+
457
+ # Runs the request and callback phases against OmniAuth.config.mock_auth
458
+ # instead of the provider when OmniAuth.config.test_mode is enabled.
459
+ module TestMode : _Core, Paths
460
+ def mock_call!: (*untyped) -> rack_response
461
+
462
+ def mock_request_call: () -> rack_response
463
+
464
+ def mock_callback_call: () -> rack_response
465
+
466
+ private
467
+
468
+ # Defined in Strategy.
469
+ def handle_phase_error: (StandardError error) -> rack_response
470
+ def run_hook: (Symbol name) -> void
471
+ end
472
+
473
+ attr_reader app: Rack::_Application
474
+ attr_reader env (): env
475
+ attr_reader options: Options
476
+ attr_reader response: untyped
477
+
478
+ def initialize: (Rack::_Application app, *untyped args) ?{ (Options) -> void } -> void
479
+
480
+ # Called with the Rack env; nil until then.
481
+ @env: env?
482
+
483
+ def inspect: () -> String
484
+
485
+ def log: (Symbol level, String message) -> void
486
+
487
+ def call: (env) -> rack_response
488
+
489
+ def call!: (env) -> rack_response
490
+
491
+ def phase_call: () -> rack_response?
492
+
493
+ def options_call?: () -> boolish
494
+
495
+ def request_call?: () -> boolish
496
+
497
+ def warn_if_using_get_on_request_path: () -> void
498
+
499
+ def options_call: () -> rack_response
500
+
501
+ def request_call: () -> rack_response
502
+
503
+ def request_response: () -> rack_response
504
+
505
+ AUTHENTICITY_PARAM: String
506
+
507
+ # The request phase's query and form params, minus the authenticity
508
+ # token, which the callback phase hands back as `omniauth.params`.
509
+ def omniauth_params: () -> Hash[String, untyped]
510
+
511
+ def store_origin: () -> void
512
+
513
+ def callback_call: () -> rack_response
514
+
515
+ def options_request?: () -> bool
516
+
517
+ # Optional. A strategy can define this to handle requests to paths
518
+ # other than its request and callback paths.
519
+ def other_phase: () -> rack_response
520
+
521
+ def setup_phase: () -> void
522
+
523
+ def request_phase: () -> rack_response
524
+
525
+ def callback_phase: () -> rack_response
526
+
527
+ def call_app!: (?env env) -> rack_response
528
+
529
+ def session: () -> Hash[String, untyped]
530
+
531
+ def request: () -> Rack::Request
532
+
533
+ def name: () -> String
534
+
535
+ def redirect: (String uri) -> rack_response
536
+
537
+ def user_info: () -> Hash[untyped, untyped]
538
+
539
+ def fail!: (String | Symbol message_key, ?Exception? exception) -> rack_response
540
+
541
+ @app: Rack::_Application
542
+ @options: Options
543
+ @request: Rack::Request?
544
+
545
+ private
546
+
547
+ def handle_phase_error: (StandardError error) -> rack_response
548
+
549
+ def run_hook: (Symbol name) -> void
550
+
551
+ def initialize_copy: (*untyped) -> void
552
+
553
+ def passthrough?: (env env) -> bool
554
+
555
+ def dispatch_by_path?: () -> bool
556
+
557
+ def path_probe: (env env) -> Strategy
558
+ end
559
+
560
+ module Strategies
561
+ # A strategy for development that asks for a name and email.
562
+ class Developer
563
+ include Strategy
564
+ extend Strategy::ClassMethods
565
+
566
+ def request_phase: () -> rack_response
567
+ end
568
+ end
569
+
570
+ module Test
571
+ # A Rack middleware that keeps one session hash across requests.
572
+ class PhonySession
573
+ def initialize: (Rack::_Application app) -> void
574
+
575
+ def call: (env) -> rack_response
576
+
577
+ @app: Rack::_Application
578
+ @session: Hash[String, untyped]?
579
+ end
580
+
581
+ # RSpec macros for strategy specs, for example:
582
+ #
583
+ # describe MyStrategy, type: :strategy do
584
+ # sets_an_auth_hash
585
+ # end
586
+ module StrategyMacros : _ExampleGroup
587
+ interface _ExampleGroup
588
+ def it: (String description) { () [self: _Example] -> void } -> void
589
+ end
590
+
591
+ # What the examples these macros define rely on: RSpec expectations
592
+ # and Rack::Test's last_request.
593
+ interface _Example
594
+ def expect: (untyped actual) -> untyped
595
+ def eq: (untyped expected) -> untyped
596
+ def be_kind_of: (Module expected) -> untyped
597
+ def last_request: () -> Rack::Request
598
+ end
599
+
600
+ def sets_an_auth_hash: () -> void
601
+
602
+ def sets_provider_to: (String provider) -> void
603
+
604
+ def sets_uid_to: (String uid) -> void
605
+
606
+ def sets_user_info_to: (Hash[untyped, untyped] user_info) -> void
607
+ end
608
+
609
+ # A test case helper that builds a Rack app around the strategy under
610
+ # test. The including test case must define #strategy and use
611
+ # Rack::Test.
612
+ module StrategyTestCase : _RackTest
613
+ interface _RackTest
614
+ def last_request: () -> Rack::Request
615
+ end
616
+
617
+ def app: () -> Rack::_Application
618
+
619
+ def app_response: () -> untyped
620
+
621
+ def session: () -> Hash[String, untyped]
622
+
623
+ def strategy: () -> Array[untyped]
624
+ end
625
+ end
626
+ end
627
+
628
+ # rack-protection doesn't ship types, so declare the classes OmniAuth's
629
+ # signatures build on.
630
+ module Rack
631
+ module Protection
632
+ class Base
633
+ end
634
+
635
+ class AuthenticityToken < Base
636
+ end
637
+ end
638
+ end