omniauth-identity 3.0.8 → 3.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.
data/README.md CHANGED
@@ -1,13 +1,76 @@
1
- # OmniAuth Identity
2
-
3
- [![Version](https://img.shields.io/gem/v/omniauth-identity.svg)](https://rubygems.org/gems/omniauth-identity)
4
- [![Depfu](https://badges.depfu.com/badges/6c9b45362951b872127f9e46d39bed76/count.svg)](https://depfu.com/github/omniauth/omniauth-identity?project_id=22381)
5
- [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fomniauth%2Fomniauth-identity%2Fbadge&style=flat)](https://actions-badge.atrox.dev/omniauth/omniauth-identity/goto)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/maintainability)](https://codeclimate.com/github/omniauth/omniauth-identity/maintainability)
7
- [![Test Coverage](https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/test_coverage)](https://codeclimate.com/github/omniauth/omniauth-identity/test_coverage)
8
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
9
- [![Open Source Helpers](https://www.codetriage.com/omniauth/omniauth-identity/badges/users.svg)](https://www.codetriage.com/omniauth/omniauth-identity)
10
- [![Downloads Rank](https://img.shields.io/gem/rd/omniauth-identity.svg)](https://rubygems.org/gems/omniauth-identity)
1
+ # `OmniAuth::Identity`
2
+
3
+ [![Version][👽versioni]][👽version]
4
+ [![License: MIT][📄license-img]][📄license-ref]
5
+ [![Downloads Rank][👽dl-ranki]][👽dl-rank]
6
+ [![Open Source Helpers][👽oss-helpi]][👽oss-help]
7
+ [![Depfu][🔑depfui♻️]][🔑depfu]
8
+ [![CodeCov][🔑codecovi♻️]][🔑codecov]
9
+ [![Test Coverage][🔑cc-covi♻️]][🔑cc-cov]
10
+ [![Maintainability][🔑cc-mnti♻️]][🔑cc-mnt]
11
+ [![CI Supported Build][🚎6-s-wfi]][🚎6-s-wf]
12
+ [![CI Legacy Build][🚎4-lg-wfi]][🚎4-lg-wf]
13
+ [![CI Unsupported Build][🚎7-us-wfi]][🚎7-us-wf]
14
+ [![CI Heads Build][🚎3-hd-wfi]][🚎3-hd-wf]
15
+ [![CI Ancient Build][🚎1-an-wfi]][🚎1-an-wf]
16
+ [![CI Coverage Build][🚎2-cov-wfi]][🚎2-cov-wf]
17
+ [![CI Style Build][🚎5-st-wfi]][🚎5-st-wf]
18
+
19
+ <!--- ( 👽️ INFO LINKS ) -->
20
+
21
+ [👽dl-rank]: https://rubygems.org/gems/omniauth-identity
22
+ [👽dl-ranki]: https://img.shields.io/gem/rd/omniauth-identity.svg
23
+ [👽oss-help]: https://www.codetriage.com/omniauth/omniauth-identity
24
+ [👽oss-helpi]: https://www.codetriage.com/omniauth/omniauth-identity/badges/users.svg
25
+ [👽version]: https://rubygems.org/gems/omniauth-identity
26
+ [👽versioni]: https://img.shields.io/gem/v/omniauth-identity.svg
27
+
28
+ <!--- ( 🔑 KEYED LINKS ) -->
29
+
30
+ [🔑cc-mnt]: https://codeclimate.com/github/omniauth/omniauth-identity/maintainability
31
+ [🔑cc-mnti♻️]: https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/maintainability
32
+ [🔑cc-cov]: https://codeclimate.com/github/omniauth/omniauth-identity/test_coverage
33
+ [🔑cc-covi♻️]: https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/test_coverage
34
+ [🔑codecov]: https://codecov.io/gh/omniauth/omniauth-identity
35
+ [🔑codecovi♻️]: https://codecov.io/gh/omniauth/omniauth-identity/graph/badge.svg?token=cc6UdZCpAL
36
+ [🔑depfu]: https://depfu.com/github/omniauth/omniauth-identity
37
+ [🔑depfui♻️]: https://badges.depfu.com/badges/6c9b45362951b872127f9e46d39bed76/count.svg
38
+
39
+ <!--- ( 🚎 BUILD LINKS ) -->
40
+
41
+ [🚎1-an-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/ancient.yml
42
+ [🚎1-an-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/ancient.yml/badge.svg
43
+ [🚎2-cov-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/coverage.yml
44
+ [🚎2-cov-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/coverage.yml/badge.svg
45
+ [🚎3-hd-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/heads.yml
46
+ [🚎3-hd-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/heads.yml/badge.svg
47
+ [🚎4-lg-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/legacy.yml
48
+ [🚎4-lg-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/legacy.yml/badge.svg
49
+ [🚎5-st-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/style.yml
50
+ [🚎5-st-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/style.yml/badge.svg
51
+ [🚎6-s-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/supported.yml
52
+ [🚎6-s-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/supported.yml/badge.svg
53
+ [🚎7-us-wf]: https://github.com/omniauth/omniauth-identity/actions/workflows/unsupported.yml
54
+ [🚎7-us-wfi]: https://github.com/omniauth/omniauth-identity/actions/workflows/unsupported.yml/badge.svg
55
+
56
+ -----
57
+
58
+ [![Liberapay Patrons][⛳liberapay-img]][⛳liberapay]
59
+ [![Sponsor Me on Github][🖇sponsor-img]][🖇sponsor]
60
+ [![Polar Shield][🖇polar-img]][🖇polar]
61
+ [![Donate to my FLOSS or refugee efforts at ko-fi.com][🖇kofi-img]][🖇kofi]
62
+ [![Donate to my FLOSS or refugee efforts using Patreon][🖇patreon-img]][🖇patreon]
63
+
64
+ [⛳liberapay-img]: https://img.shields.io/liberapay/patrons/pboling.svg?logo=liberapay
65
+ [⛳liberapay]: https://liberapay.com/pboling/donate
66
+ [🖇sponsor-img]: https://img.shields.io/badge/Sponsor_Me!-pboling.svg?style=social&logo=github
67
+ [🖇sponsor]: https://github.com/sponsors/pboling
68
+ [🖇polar-img]: https://polar.sh/embed/seeks-funding-shield.svg?org=pboling
69
+ [🖇polar]: https://polar.sh/pboling
70
+ [🖇kofi-img]: https://img.shields.io/badge/buy%20me%20coffee-donate-yellow.svg
71
+ [🖇kofi]: https://ko-fi.com/O5O86SNP4
72
+ [🖇patreon-img]: https://img.shields.io/badge/patreon-donate-yellow.svg
73
+ [🖇patreon]: https://patreon.com/galtzo
11
74
 
12
75
  The OmniAuth Identity gem provides a way for applications to utilize a
13
76
  traditional username/password based authentication system without the need
@@ -15,27 +78,63 @@ to give up the simple authentication flow provided by OmniAuth. Identity
15
78
  is designed on purpose to be as featureless as possible: it provides the
16
79
  basic construct for user management and then gets out of the way.
17
80
 
18
- ## Compatibility
19
-
20
- This gem is compatible with, as of Feb 2021, version 3:
21
-
22
- * Latest released version of omniauth, v2.0.2
23
- * Ruby 2.4, 2.5, 2.6, 2.7, 3.0, ruby-head
81
+ | Primary Namespace | `OmniAuth::Identity` |
82
+ |-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
83
+ | documentation | [on Github.com][homepage], [Latest release on RubyDoc.info][documentation], [HEAD on RubyDoc.info][documentation-head] |
84
+ | expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
85
+ | `...` 💖 | [![Follow Me on LinkedIn][🖇linkedin-img]][🖇linkedin] [![Find Me on WellFound:][✌️wellfound-img]][✌️wellfound] [![Find Me on CrunchBase][💲crunchbase-img]][💲crunchbase] [![My LinkTree][🌳linktree-img]][🌳linktree] [![Follow Me on Ruby.Social][🐘ruby-mast-img]][🐘ruby-mast] [![Tweet @ Peter][🐦tweet-img]][🐦tweet] [💻][coderme] [🌏][aboutme] |
86
+
87
+ <!--- 7️⃣ spread 💖 -->
88
+ [🐦tweet-img]: https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow%20%40galtzo
89
+ [🐦tweet]: http://twitter.com/galtzo
90
+ [🚎blog]: http://www.railsbling.com/tags/omniauth-identity/
91
+ [🚎blog-img]: https://img.shields.io/badge/blog-railsbling-brightgreen.svg?style=flat
92
+ [🖇linkedin]: http://www.linkedin.com/in/peterboling
93
+ [🖇linkedin-img]: https://img.shields.io/badge/PeterBoling-blue?style=plastic&logo=linkedin
94
+ [✌️wellfound]: https://angel.co/u/peter-boling
95
+ [✌️wellfound-img]: https://img.shields.io/badge/peter--boling-orange?style=plastic&logo=wellfound
96
+ [💲crunchbase]: https://www.crunchbase.com/person/peter-boling
97
+ [💲crunchbase-img]: https://img.shields.io/badge/peter--boling-purple?style=plastic&logo=crunchbase
98
+ [🐘ruby-mast]: https://ruby.social/@galtzo
99
+ [🐘ruby-mast-img]: https://img.shields.io/mastodon/follow/109447111526622197?domain=https%3A%2F%2Fruby.social&style=plastic&logo=mastodon&label=Ruby%20%40galtzo
100
+ [🌳linktree]: https://linktr.ee/galtzo
101
+ [🌳linktree-img]: https://img.shields.io/badge/galtzo-purple?style=plastic&logo=linktree
102
+
103
+ <!--- Maintainer Contact Links -->
104
+ [aboutme]: https://about.me/peter.boling
105
+ [coderme]: https://coderwall.com/Peter%20Boling
24
106
 
25
107
  ## Installation
26
108
 
27
- To acquire the latest release from RubyGems add the following to your `Gemfile`:
109
+ To acquire the latest release from RubyGems, and add this gem to your `Gemfile`, run:
28
110
 
29
- ```ruby
30
- gem 'omniauth-identity'
111
+ ```shell
112
+ bundle add omniauth-identity
31
113
  ```
32
114
 
33
115
  If the git repository has new commits not yet in an official release, simply specify the repo instead:
34
116
 
35
117
  ```ruby
36
- gem 'omniauth-identity', git: 'https://github.com/intridea/omniauth-identity.git'
118
+ gem "omniauth-identity", git: "https://github.com/omniauth/omniauth-identity.git"
37
119
  ```
38
120
 
121
+ ## Compatibility
122
+
123
+ This gem is compatible with a wide range of Ruby versions and Ruby ORMs, as of Nov 2024, version 3.1.
124
+
125
+ * Latest released version of omniauth, v2+
126
+ * Tested in CI against Ruby 2.5, 2.6, 2.7, 3.0, 3.1, 3.2, 3.3, ruby-head, truffleruby-head
127
+ * Probably also compatible with Ruby 2.4 and jruby-head
128
+ * At least 5 different database ORM adapters, which connect to 15 different database clients!
129
+
130
+ | Databases | Adapter Libraries |
131
+ |-----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
132
+ | MySQL, PostgreSQL, SQLite3 | [ActiveRecord](https://guides.rubyonrails.org/active_record_basics.html) |
133
+ | CouchDB | [CouchPotato](https://github.com/langalex/couch_potato) |
134
+ | MongoDB | [Mongoid](https://github.com/mongodb/mongoid) |
135
+ | RethinkDB | [NoBrainer](http://nobrainer.io/) |
136
+ | ADO, Amalgalite, IBM_DB, JDBC, MySQL, Mysql2, ODBC, Oracle, PostgreSQL, SQLAnywhere, SQLite3, and TinyTDS | [Sequel](http://sequel.jeremyevans.net) |
137
+
39
138
  ## Usage
40
139
 
41
140
  This can be a bit hard to understand the first time. Luckily, Ryan Bates made
@@ -48,8 +147,8 @@ Rack middleware. In rails, this would be created by an initializer, such as
48
147
  ```ruby
49
148
  use OmniAuth::Builder do
50
149
  provider :identity, #mandatory: tells OA that the Identity strategy is being used
51
- model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
52
- fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
150
+ model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
151
+ fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
53
152
  end
54
153
  ```
55
154
 
@@ -100,7 +199,6 @@ class SequelTestIdentity < Sequel::Model(:identities)
100
199
  end
101
200
  ```
102
201
 
103
-
104
202
  ### Mongoid
105
203
 
106
204
  Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
@@ -171,7 +269,7 @@ end
171
269
  ```
172
270
 
173
271
  NOTE: In the above example, `MyCustomClass` must have a class method called `auth_key` that returns
174
- the default (`email`) or custom `auth_key` to use.
272
+ the default (`email`) or custom `auth_key` to use.
175
273
 
176
274
  ## Customizing Registration Failure
177
275
 
@@ -212,8 +310,8 @@ fails. In your OmniAuth configuration, specify any valid rack endpoint in the
212
310
  ```ruby
213
311
  use OmniAuth::Builder do
214
312
  provider :identity,
215
- fields: [:email],
216
- on_failed_registration: UsersController.action(:new)
313
+ fields: [:email],
314
+ on_failed_registration: UsersController.action(:new)
217
315
  end
218
316
  ```
219
317
 
@@ -232,7 +330,7 @@ The default value is:
232
330
  ```ruby
233
331
  use OmniAuth::Builder do
234
332
  provider :identity,
235
- locate_conditions: ->(req) { { model.auth_key => req['auth_key'] } }
333
+ locate_conditions: ->(req) { {model.auth_key => req.params["auth_key"]} }
236
334
  # ...
237
335
  end
238
336
  ```
@@ -261,60 +359,123 @@ option :on_login, nil # See #request_phase
261
359
  option :on_validation, nil # See #registration_phase
262
360
  option :on_registration, nil # See #registration_phase
263
361
  option :on_failed_registration, nil # See #registration_phase
264
- option :locate_conditions, ->(req) { { model.auth_key => req['auth_key'] } }
362
+ option :locate_conditions, ->(req) { {model.auth_key => req.params["auth_key"]} }
265
363
  ```
266
364
 
267
365
  Please contribute some documentation if you have the gumption! The maintainer's time is limited, and sometimes the authors of PRs with new options don't update the _this_ readme. 😭
268
366
 
269
- ## Contributing
270
-
271
- 1. Fork it
272
- 2. Create your feature branch (`git checkout -b my-new-feature`)
273
- 3. Commit your changes (`git commit -am ‘Added some feature’`)
274
- 4. Push to the branch (`git push origin my-new-feature`)
275
- 5. Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
276
- - NOTE: In order to run *all* the tests you will need to have the following databases installed, configured, and running.
277
- 1. [RethinkDB](https://rethinkdb.com), an open source, real-time, web database, [installed](https://rethinkdb.com/docs/install/) and [running](https://rethinkdb.com/docs/start-a-server/), e.g.
278
- ```bash
279
- brew install rethinkdb
280
- rethinkdb
281
- ```
282
- 2. [MongoDB](https://docs.mongodb.com/manual/administration/install-community/)
283
- ```bash
284
- brew tap mongodb/brew
285
- brew install mongodb-community@4.4
286
- mongod --config /usr/local/etc/mongod.conf
287
- ```
288
- 3. [CouchDB](https://couchdb.apache.org) (download the .app)
289
- To run all tests on all databases:
290
- ```bash
291
- bundle exec rake
292
- ```
293
- To run a specific DB:
294
- ```bash
295
- # CouchDB / CouchPotato
296
- bundle exec rspec spec spec_orms --tag 'couchdb'
297
-
298
- # ActiveRecord and Sequel, as they both use the in-memory SQLite driver.
299
- bundle exec rspec spec spec_orms --tag 'sqlite3'
300
-
301
- # NOTE - mongoid and nobrainer specs can't be isolated with "tag" because it still loads everything,
302
- # and the two libraries are fundamentally incompatible.
303
-
304
- # MongoDB / Mongoid
305
- bundle exec rspec spec_orms/mongoid_spec.rb
306
-
307
- # RethinkDB / NoBrainer
308
- bundle exec rspec spec_orms/nobrainer_spec.rb
309
- ```
310
- 6. Create new Pull Request
311
-
312
- ## License
313
-
314
- MIT License. See LICENSE for details.
315
-
316
- ## Copyright
317
-
318
- * Copyright (c) 2021 OmniAuth-Identity Maintainers
319
- * Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
367
+ ## 🤝 Contributing
368
+
369
+ If you need some ideas of where to help, you could work on adding more code coverage,
370
+ or if it is already 💯 (see [below](#code-coverage)) then check [issues][🤝issues], or [PRs][🤝pulls],
371
+ or use the gem and think about how it could be better.
372
+
373
+ Also, see [CONTRIBUTING.md][🤝contributing].
374
+
375
+ [🤝issues]: https://github.com/omniauth/omniauth-identity/issues
376
+ [🤝pulls]: https://github.com/omniauth/omniauth-identity/pulls
377
+ [🤝contributing]: CONTRIBUTING.md
378
+
379
+ ### Code Coverage
380
+
381
+ [![Coverage Graph][🔑codecov-g]][🔑codecov]
382
+
383
+ [🔑codecov-g]: https://codecov.io/gh/omniauth/omniauth-identity/graphs/tree.svg?token=cc6UdZCpAL
384
+
385
+ ## 🌈 Contributors
386
+
387
+ [![Contributors][🖐contributors-img]][🖐contributors]
388
+
389
+ Made with [contributors-img][🖐contrib-rocks].
390
+
391
+ [🖐contrib-rocks]: https://contrib.rocks
392
+ [🖐contributors]: https://github.com/omniauth/omniauth-identity/graphs/contributors
393
+ [🖐contributors-img]: https://contrib.rocks/image?repo=omniauth/omniauth-identity
394
+
395
+ ## Star History
396
+
397
+ <a href="https://star-history.com/#omniauth/omniauth-identity&Date">
398
+ <picture>
399
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=omniauth/omniauth-identity&type=Date&theme=dark" />
400
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=omniauth/omniauth-identity&type=Date" />
401
+ <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=omniauth/omniauth-identity&type=Date" />
402
+ </picture>
403
+ </a>
404
+
405
+ ## 🪇 Code of Conduct
406
+
407
+ Everyone interacting in this project's codebases, issue trackers,
408
+ chat rooms and mailing lists is expected to follow the [code of conduct][🪇conduct].
409
+
410
+ [🪇conduct]: CODE_OF_CONDUCT.md
411
+
412
+ ## 📌 Versioning
413
+
414
+ This Library adheres to [Semantic Versioning 2.0.0][📌semver].
415
+ Violations of this scheme should be reported as bugs.
416
+ Specifically, if a minor or patch version is released that breaks backward compatibility,
417
+ a new version should be immediately released that restores compatibility.
418
+ Breaking changes to the public API will only be introduced with new major versions.
419
+
420
+ To get a better understanding of how SemVer is intended to work over a project's lifetime,
421
+ read this article from the creator of SemVer:
422
+
423
+ - ["Major Version Numbers are Not Sacred"][📌major-versions-not-sacred]
424
+
425
+ As a result of this policy, you can (and should) specify a dependency on these libraries using
426
+ the [Pessimistic Version Constraint][📌pvc] with two digits of precision.
427
+
428
+ For example:
429
+
430
+ ```ruby
431
+ spec.add_dependency("omniauth-identity", "~> 3.1")
432
+ ```
433
+
434
+ See [CHANGELOG.md][📌changelog] for list of releases.
435
+
436
+ <!--- ( 📌 VERSIONING LINKS ) -->
437
+
438
+ [📌pvc]: http://guides.rubygems.org/patterns/#pessimistic-version-constraint
439
+ [📌semver]: http://semver.org/
440
+ [📌major-versions-not-sacred]: https://tom.preston-werner.com/2022/05/23/major-version-numbers-are-not-sacred.html
441
+ [📌changelog]: CHANGELOG.md
442
+
443
+ ## 📄 License
444
+
445
+ The gem is available as open source under the terms of
446
+ the [MIT License][📄license] [![License: MIT][📄license-img]][📄license-ref].
447
+ See [LICENSE.txt][📄license] for the official [Copyright Notice][📄copyright-notice-explainer].
448
+
449
+ [comment]: <> ( 📄 LEGAL LINKS )
450
+
451
+ [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
452
+ [📄license]: LICENSE.txt
453
+ [📄license-ref]: https://opensource.org/licenses/MIT
454
+ [📄license-img]: https://img.shields.io/badge/License-MIT-green.svg
455
+
456
+ ### © Copyright
457
+
458
+ * Copyright (c) 2021, 2024 [Peter H. Boling][peterboling], and OmniAuth-Identity Maintainers
459
+ * Copyright (c) 2020 [Peter H. Boling][peterboling], Andrew Roberts, and Jellybooks Ltd.
320
460
  * Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.
461
+
462
+ [railsbling]: http://www.railsbling.com
463
+ [peterboling]: http://www.peterboling.com
464
+ [bundle-group-pattern]: https://gist.github.com/pboling/4564780
465
+ [documentation]: http://rubydoc.info/gems/omniauth-identity
466
+ [documentation-head]: https://rubydoc.info/github/omniauth/omniauth-identity/main
467
+ [homepage]: https://github.com/omniauth/omniauth-identity
468
+
469
+ ## 🤑 One more thing
470
+
471
+ You made it to the bottom of the page,
472
+ so perhaps you'll indulge me for another 20 seconds.
473
+ I maintain many dozens of gems, including this one,
474
+ because I want Ruby to be a great place for people to solve problems, big and small.
475
+ Please consider supporting my efforts via the giant yellow link below,
476
+ or one of the others at the head of this README.
477
+
478
+ [![Buy me a latte][🖇buyme-img]][🖇buyme]
479
+
480
+ [🖇buyme-img]: https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
481
+ [🖇buyme]: https://www.buymeacoffee.com/pboling
@@ -2,7 +2,7 @@
2
2
 
3
3
  module OmniAuth
4
4
  module Identity
5
- # This module provides an includable interface for implementing the
5
+ # This module provides an include-able interface for implementing the
6
6
  # necessary API for OmniAuth Identity to properly locate identities
7
7
  # and provide all necessary information.
8
8
  #
@@ -23,20 +23,22 @@ module OmniAuth
23
23
  module Model
24
24
  SCHEMA_ATTRIBUTES = %w[name email nickname first_name last_name location description image phone].freeze
25
25
 
26
- def self.included(base)
27
- base.extend ClassMethods
28
- base.extend ClassCreateApi unless base.respond_to?(:create)
29
- im = base.instance_methods
30
- base.include InstanceSaveApi unless im.include?(:save)
31
- base.include InstancePersistedApi unless im.include?(:persisted?)
26
+ class << self
27
+ def included(base)
28
+ base.extend(ClassMethods)
29
+ base.extend(ClassCreateApi) unless base.respond_to?(:create)
30
+ i_methods = base.instance_methods
31
+ base.include(InstanceSaveApi) unless i_methods.include?(:save)
32
+ base.include(InstancePersistedApi) unless i_methods.include?(:persisted?)
33
+ end
32
34
  end
33
35
 
34
36
  module ClassMethods
35
37
  # Authenticate a user with the given key and password.
36
38
  #
37
- # @param [String] key The unique login key provided for a given identity.
39
+ # @param [String] conditions The unique login key provided for a given identity.
38
40
  # @param [String] password The presumed password for the identity.
39
- # @return [Model] An instance of the identity model class.
41
+ # @return [Model, false] An instance of the identity model class.
40
42
  def authenticate(conditions, password)
41
43
  instance = locate(conditions)
42
44
  return false unless instance
@@ -49,15 +51,15 @@ module OmniAuth
49
51
  # @return [String] The method name.
50
52
  def auth_key(method = false)
51
53
  @auth_key = method.to_s unless method == false
52
- @auth_key = nil if !defined?(@auth_key) || @auth_key == ''
54
+ @auth_key = nil if !defined?(@auth_key) || @auth_key == ""
53
55
 
54
- @auth_key || 'email'
56
+ @auth_key || "email"
55
57
  end
56
58
 
57
59
  # Locate an identity given its unique login key.
58
60
  #
59
61
  # @abstract
60
- # @param [String] key The unique login key.
62
+ # @param [String] _key The unique login key.
61
63
  # @return [Model] An instance of the identity model class.
62
64
  def locate(_key)
63
65
  raise NotImplementedError
@@ -71,7 +73,7 @@ module OmniAuth
71
73
  #
72
74
  # @deprecated v4.0 will begin using {#new} with {#save} instead.
73
75
  # @abstract
74
- # @param [Hash] args Attributes of the new instance.
76
+ # @param [Hash] _args Attributes of the new instance.
75
77
  # @return [Model] An instance of the identity model class.
76
78
  # @since 3.0.5
77
79
  def create(*_args)
@@ -109,7 +111,7 @@ module OmniAuth
109
111
  # otherwise.
110
112
  #
111
113
  # @abstract
112
- # @param [String] password The password to check.
114
+ # @param [String] _password The password to check.
113
115
  # @return [self or false] Self if authenticated, false if not.
114
116
  def authenticate(_password)
115
117
  raise NotImplementedError
@@ -121,7 +123,7 @@ module OmniAuth
121
123
  # @return [String] An identifier string unique to this identity.
122
124
  def uid
123
125
  if respond_to?(:id)
124
- return nil if id.nil?
126
+ return if id.nil?
125
127
 
126
128
  id.to_s
127
129
  else
@@ -172,8 +174,8 @@ module OmniAuth
172
174
  SCHEMA_ATTRIBUTES.each_with_object(info) do |attribute, hash|
173
175
  hash[attribute] = send(attribute) if respond_to?(attribute)
174
176
  end
175
- info['name'] ||= [info['first_name'], info['last_name']].join(' ').strip if info['first_name'] || info['last_name']
176
- info['name'] ||= info['nickname']
177
+ info["name"] ||= [info["first_name"], info["last_name"]].join(" ").strip if info["first_name"] || info["last_name"]
178
+ info["name"] ||= info["nickname"]
177
179
  info
178
180
  end
179
181
  end
@@ -1,24 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'active_record'
3
+ require "active_record"
4
4
 
5
5
  module OmniAuth
6
6
  module Identity
7
7
  module Models
8
+ # ActiveRecord is an ORM for MySQL, PostgreSQL, and SQLite3:
9
+ # https://guides.rubyonrails.org/active_record_basics.html
10
+ # NOTE: ActiveRecord is based on ActiveModel.
8
11
  class ActiveRecord < ::ActiveRecord::Base
9
12
  include ::OmniAuth::Identity::Model
10
13
  include ::OmniAuth::Identity::SecurePassword
11
14
 
12
15
  self.abstract_class = true
16
+ # validations: true (default) incurs a dependency on ActiveModel, but ActiveRecord is ActiveModel based.
13
17
  has_secure_password
14
18
 
15
19
  def self.auth_key=(key)
16
20
  super
17
- validates_uniqueness_of key, case_sensitive: false
21
+ validates_uniqueness_of(key, case_sensitive: false)
18
22
  end
19
23
 
20
24
  def self.locate(search_hash)
21
- search_hash = search_hash.reverse_merge!('provider' => 'identity') if column_names.include?('provider')
25
+ search_hash = search_hash.reverse_merge!("provider" => "identity") if column_names.include?("provider")
22
26
  where(search_hash).first
23
27
  end
24
28
  end
@@ -1,24 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'couch_potato'
3
+ require "couch_potato"
4
4
 
5
5
  module OmniAuth
6
6
  module Identity
7
7
  module Models
8
- # can not be named CouchPotato since there is a class with that name
8
+ # CouchPotato is an ORM adapter for CouchDB:
9
+ # https://github.com/langalex/couch_potato
9
10
  # NOTE: CouchPotato is based on ActiveModel.
10
11
  # NOTE: CouchPotato::Persistence must be included before OmniAuth::Identity::Models::CouchPotatoModule
12
+ # NOTE: Includes "Module" in the name for invalid legacy reasons. Rename only with a major version bump.
11
13
  module CouchPotatoModule
12
14
  def self.included(base)
13
15
  base.class_eval do
14
- include ::OmniAuth::Identity::Model
15
- include ::OmniAuth::Identity::SecurePassword
16
+ include(::OmniAuth::Identity::Model)
17
+ include(::OmniAuth::Identity::SecurePassword)
16
18
 
19
+ # validations: true (default) incurs a dependency on ActiveModel, but CouchPotato is ActiveModel based.
17
20
  has_secure_password
18
21
 
19
22
  def self.auth_key=(key)
20
23
  super
21
- validates_uniqueness_of key, case_sensitive: false
24
+ validates_uniqueness_of(key, case_sensitive: false)
22
25
  end
23
26
 
24
27
  def self.locate(search_hash)
@@ -26,7 +29,7 @@ module OmniAuth
26
29
  end
27
30
 
28
31
  def save
29
- CouchPotato.database.save(self)
32
+ CouchPotato.database.save_document(self)
30
33
  end
31
34
  end
32
35
  end
@@ -1,22 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'mongoid'
3
+ require "mongoid"
4
4
 
5
5
  module OmniAuth
6
6
  module Identity
7
7
  module Models
8
+ # Mongoid is an ORM adapter for MongoDB:
9
+ # https://github.com/mongodb/mongoid
8
10
  # NOTE: Mongoid is based on ActiveModel.
9
11
  module Mongoid
10
12
  def self.included(base)
11
13
  base.class_eval do
12
- include ::OmniAuth::Identity::Model
13
- include ::OmniAuth::Identity::SecurePassword
14
+ include(::OmniAuth::Identity::Model)
15
+ include(::OmniAuth::Identity::SecurePassword)
14
16
 
17
+ # validations: true (default) incurs a dependency on ActiveModel, but Mongoid is ActiveModel based.
15
18
  has_secure_password
16
19
 
17
20
  def self.auth_key=(key)
18
21
  super
19
- validates_uniqueness_of key, case_sensitive: false
22
+ validates_uniqueness_of(key, case_sensitive: false)
20
23
  end
21
24
 
22
25
  def self.locate(search_hash)
@@ -1,23 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'nobrainer'
3
+ require "nobrainer"
4
4
 
5
5
  module OmniAuth
6
6
  module Identity
7
7
  module Models
8
- # http://nobrainer.io/ an ORM for RethinkDB
8
+ # NoBrainer is an ORM adapter for RethinkDB:
9
+ # http://nobrainer.io/
9
10
  # NOTE: NoBrainer is based on ActiveModel.
10
11
  module NoBrainer
11
12
  def self.included(base)
12
13
  base.class_eval do
13
- include ::OmniAuth::Identity::Model
14
- include ::OmniAuth::Identity::SecurePassword
14
+ include(::OmniAuth::Identity::Model)
15
+ include(::OmniAuth::Identity::SecurePassword)
15
16
 
17
+ # validations: true (default) incurs a dependency on ActiveModel, but NoBrainer is ActiveModel based.
16
18
  has_secure_password
17
19
 
18
20
  def self.auth_key=(key)
19
21
  super
20
- validates_uniqueness_of key, case_sensitive: false
22
+ validates_uniqueness_of(key, case_sensitive: false)
21
23
  end
22
24
 
23
25
  def self.locate(search_hash)