omniauth-identity 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ae0c6e9acba482e20f1284d42f157beb243b7efe00913b420e1d97ee158d0d2
4
- data.tar.gz: c113d2a6e9f701ae8b7a524e7aede16bfce000f593f194e577b38a2cb02a10c0
3
+ metadata.gz: 3f6fae0f25aadccc74594334c90cf581c141a7fb68cbe50f26638648aa0fbbe4
4
+ data.tar.gz: 6998b461e27a72cc4da0cd4ca80f63e284fbf9fbff466b40ec1df736e511516d
5
5
  SHA512:
6
- metadata.gz: 4f8cbd06676c3b16661651bf161e4bf819e8b48529aec572d2a7ddb52e5a4dde87bf52e71933be86af22486f03b4a4d5710417db79803b1bba93357258122330
7
- data.tar.gz: 36a5d520208b6d0754d5d3e7fb7990b27b9bd967b598039bf6d37bf0e8167e2e8c7689df79a8aeee9a6d9187b2a1d2653d02e99025444157183d0072323807ae
6
+ metadata.gz: e209c51695fef0b79d0b57360acb1f9dc464a0424f96e1ab87b9847c0de7350c677a057c7cedb7e587428465c6fb8eaefb53a644fae18b5a9c574d82a0fdaf86
7
+ data.tar.gz: 542dd3902564af08c6c6653b381ce545278ef759e0b0861df62a8e19a118cabf022143db267c81525a26e944679770f8e8b62c1a4f93282c55505bcc56442dd4
data/CHANGELOG.md CHANGED
@@ -6,9 +6,20 @@ All notable changes to this project will be documented in this file.
6
6
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7
7
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8
8
 
9
+ ## [Unreleased]
10
+
11
+ ### Added
12
+ - Add option `:enable_login` to bypass OmniAuth disabling of GET method (default `true`)
13
+ - NOTE: This restores compatibility between this gem and the current, core, omniauth gem!
14
+ - README updates, including a rename to README.md
15
+
16
+ ### Removed
17
+ - Removed support for DataMapper, which died long ago.
18
+ - Cleanup (removal) of unwanted git artifacts
19
+
9
20
  ## [2.0] - 2020-09-01
10
21
 
11
- ### Added
22
+ ### Added
12
23
  - CHANGELOG to maintain a history of changes.
13
24
  - Include mongoid-rspec gem.
14
25
 
@@ -0,0 +1,133 @@
1
+
2
+ # Contributor Covenant Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We as members, contributors, and leaders pledge to make participation in our
7
+ community a harassment-free experience for everyone, regardless of age, body
8
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
9
+ identity and expression, level of experience, education, socio-economic status,
10
+ nationality, personal appearance, race, religion, or sexual identity
11
+ and orientation.
12
+
13
+ We pledge to act and interact in ways that contribute to an open, welcoming,
14
+ diverse, inclusive, and healthy community.
15
+
16
+ ## Our Standards
17
+
18
+ Examples of behavior that contributes to a positive environment for our
19
+ community include:
20
+
21
+ * Demonstrating empathy and kindness toward other people
22
+ * Being respectful of differing opinions, viewpoints, and experiences
23
+ * Giving and gracefully accepting constructive feedback
24
+ * Accepting responsibility and apologizing to those affected by our mistakes,
25
+ and learning from the experience
26
+ * Focusing on what is best not just for us as individuals, but for the
27
+ overall community
28
+
29
+ Examples of unacceptable behavior include:
30
+
31
+ * The use of sexualized language or imagery, and sexual attention or
32
+ advances of any kind
33
+ * Trolling, insulting or derogatory comments, and personal or political attacks
34
+ * Public or private harassment
35
+ * Publishing others' private information, such as a physical or email
36
+ address, without their explicit permission
37
+ * Other conduct which could reasonably be considered inappropriate in a
38
+ professional setting
39
+
40
+ ## Enforcement Responsibilities
41
+
42
+ Community leaders are responsible for clarifying and enforcing our standards of
43
+ acceptable behavior and will take appropriate and fair corrective action in
44
+ response to any behavior that they deem inappropriate, threatening, offensive,
45
+ or harmful.
46
+
47
+ Community leaders have the right and responsibility to remove, edit, or reject
48
+ comments, commits, code, wiki edits, issues, and other contributions that are
49
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
50
+ decisions when appropriate.
51
+
52
+ ## Scope
53
+
54
+ This Code of Conduct applies within all community spaces, and also applies when
55
+ an individual is officially representing the community in public spaces.
56
+ Examples of representing our community include using an official e-mail address,
57
+ posting via an official social media account, or acting as an appointed
58
+ representative at an online or offline event.
59
+
60
+ ## Enforcement
61
+
62
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
63
+ reported to the community leaders responsible for enforcement at
64
+ [INSERT CONTACT METHOD].
65
+ All complaints will be reviewed and investigated promptly and fairly.
66
+
67
+ All community leaders are obligated to respect the privacy and security of the
68
+ reporter of any incident.
69
+
70
+ ## Enforcement Guidelines
71
+
72
+ Community leaders will follow these Community Impact Guidelines in determining
73
+ the consequences for any action they deem in violation of this Code of Conduct:
74
+
75
+ ### 1. Correction
76
+
77
+ **Community Impact**: Use of inappropriate language or other behavior deemed
78
+ unprofessional or unwelcome in the community.
79
+
80
+ **Consequence**: A private, written warning from community leaders, providing
81
+ clarity around the nature of the violation and an explanation of why the
82
+ behavior was inappropriate. A public apology may be requested.
83
+
84
+ ### 2. Warning
85
+
86
+ **Community Impact**: A violation through a single incident or series
87
+ of actions.
88
+
89
+ **Consequence**: A warning with consequences for continued behavior. No
90
+ interaction with the people involved, including unsolicited interaction with
91
+ those enforcing the Code of Conduct, for a specified period of time. This
92
+ includes avoiding interactions in community spaces as well as external channels
93
+ like social media. Violating these terms may lead to a temporary or
94
+ permanent ban.
95
+
96
+ ### 3. Temporary Ban
97
+
98
+ **Community Impact**: A serious violation of community standards, including
99
+ sustained inappropriate behavior.
100
+
101
+ **Consequence**: A temporary ban from any sort of interaction or public
102
+ communication with the community for a specified period of time. No public or
103
+ private interaction with the people involved, including unsolicited interaction
104
+ with those enforcing the Code of Conduct, is allowed during this period.
105
+ Violating these terms may lead to a permanent ban.
106
+
107
+ ### 4. Permanent Ban
108
+
109
+ **Community Impact**: Demonstrating a pattern of violation of community
110
+ standards, including sustained inappropriate behavior, harassment of an
111
+ individual, or aggression toward or disparagement of classes of individuals.
112
+
113
+ **Consequence**: A permanent ban from any sort of public interaction within
114
+ the community.
115
+
116
+ ## Attribution
117
+
118
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
+ version 2.0, available at
120
+ [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121
+
122
+ Community Impact Guidelines were inspired by
123
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
+
125
+ For answers to common questions about this code of conduct, see the FAQ at
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127
+ at [https://www.contributor-covenant.org/translations][translations].
128
+
129
+ [homepage]: https://www.contributor-covenant.org
130
+ [v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
131
+ [Mozilla CoC]: https://github.com/mozilla/diversity
132
+ [FAQ]: https://www.contributor-covenant.org/faq
133
+ [translations]: https://www.contributor-covenant.org/translations
@@ -6,24 +6,47 @@ to give up the simple authentication flow provided by OmniAuth. Identity
6
6
  is designed on purpose to be as featureless as possible: it provides the
7
7
  basic construct for user management and then gets out of the way.
8
8
 
9
+ ## Compatibility
10
+
11
+ This gem is compatible with, as of Feb 2021:
12
+ • latest released version of omniauth, v2.0.2
13
+ • Ruby 2.4, 2.5, 2.6, 2.7
14
+
15
+ ## Installation
16
+
17
+ To acquire the latest release from RubyGems add the following to your `Gemfile`:
18
+
19
+ ```ruby
20
+ gem 'omniauth-identity'
21
+ ```
22
+
23
+ If the git repository has new commits not yet in an official release, simply specify the repo instead:
24
+
25
+ ```ruby
26
+ gem 'omniauth-identity', git: 'https://github.com/intridea/omniauth-identity.git'
27
+ ```
28
+
9
29
  ## Usage
10
30
 
11
31
  This can be a bit hard to understand the first time. Luckily, Ryan Bates made
12
32
  a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
13
33
 
14
34
  You use `omniauth-identity` just like you would any other OmniAuth provider: as a
15
- Rack middleware. The basic setup for a email/password authentication would
16
- look something like this:
35
+ Rack middleware. In rails, this would be created by an initializer, such as
36
+ `config/initializers/omniauth.rb`. The basic setup for a email/password authentication would look something like this:
17
37
 
18
38
  ```ruby
19
39
  use OmniAuth::Builder do
20
- provider :identity, :fields => [:email]
40
+ provider :identity, #mandatory: tells OA that the Identity strategy is being used
41
+ model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
42
+ fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
21
43
  end
22
44
  ```
23
45
 
24
- Next, you need to create a model (called `Identity by default`) that will be
25
- able to persist the information provided by the user. Luckily for you, there
26
- are pre-built models for popular ORMs that make this dead simple.
46
+ Next, you need to create a model (called `Identity` by default, or specified
47
+ with `:model` argument above) that will be able to persist the information
48
+ provided by the user. Luckily for you, there are pre-built models for popular
49
+ ORMs that make this dead simple.
27
50
 
28
51
  **Note:** OmniAuth Identity is different from many other user authentication
29
52
  systems in that it is *not* built to store authentication information in your primary
@@ -38,7 +61,10 @@ in the database for all of the fields you are using.
38
61
 
39
62
  ```ruby
40
63
  class Identity < OmniAuth::Identity::Models::ActiveRecord
41
- # Add whatever you like!
64
+ auth_key :email # optional: specifies the field within the model that will be used during the login process
65
+ # defaults to email, but may be username, uid, login, etc.
66
+
67
+ # Anything else you want!
42
68
  end
43
69
  ```
44
70
 
@@ -60,12 +86,12 @@ end
60
86
 
61
87
  ### MongoMapper
62
88
 
63
- Unfortunately MongoMapper is **not supported** in `omniauth-identity` from >= v2.0 as a result of it
89
+ Unfortunately MongoMapper is **not supported** in `omniauth-identity` from >= v2.0 as a result of it
64
90
  not being maintained for several years.
65
91
 
66
- It wasn't possible to include Mongoid *and* MongoMapper due to incompatible gem version
67
- requirements. Therefore precedence was given to Mongoid as it is significantly more
68
- popular and actively maintained.
92
+ It wasn't possible to include Mongoid *and* MongoMapper due to incompatible gem version
93
+ requirements. Therefore precedence was given to Mongoid as it is significantly more
94
+ popular and actively maintained.
69
95
 
70
96
  ### DataMapper
71
97
 
@@ -82,7 +108,6 @@ class Identity
82
108
  property :password_digest, Text
83
109
 
84
110
  attr_accessor :password_confirmation
85
-
86
111
  end
87
112
  ```
88
113
 
@@ -98,15 +123,15 @@ class Identity
98
123
  property :email
99
124
  property :password_digest
100
125
 
101
- def self.where search_hash
102
- CouchPotato.database.view Identity.by_email(:key => search_hash)
126
+ def self.where(search_hash)
127
+ CouchPotato.database.view(Identity.by_email(key: search_hash))
103
128
  end
104
129
 
105
- view :by_email, :key => :email
130
+ view :by_email, key: :email
106
131
  end
107
132
  ```
108
133
 
109
- Once you've got an Identity persistence model and the strategy up and
134
+ Once you've got an `Identity` persistence model and the strategy up and
110
135
  running, you can point users to `/auth/identity` and it will request
111
136
  that they log in or give them the opportunity to sign up for an account.
112
137
  Once they have authenticated with their identity, OmniAuth will call
@@ -121,14 +146,17 @@ different class.
121
146
 
122
147
  ```ruby
123
148
  use OmniAuth::Builder do
124
- provider :identity, :fields => [:email], :model => MyCustomClass
149
+ provider :identity, fields: [:email], model: MyCustomClass
125
150
  end
126
151
  ```
127
152
 
153
+ NOTE: In the above example, `MyCustomClass` must have a class method called `auth_key` that returns
154
+ the default (`email`) or custom `auth_key` to use.
155
+
128
156
  ## Customizing Registration Failure
129
157
 
130
158
  To use your own custom registration form, create a form that POSTs to
131
- '/auth/identity/register' with 'password', 'password_confirmation', and your
159
+ `/auth/identity/register` with `password`, `password_confirmation`, and your
132
160
  other fields.
133
161
 
134
162
  ```erb
@@ -144,7 +172,7 @@ other fields.
144
172
  Beware not to nest your form parameters within a namespace. This strategy
145
173
  looks for the form parameters at the top level of the post params. If you are
146
174
  using [simple\_form](https://github.com/plataformatec/simple_form), then you
147
- can avoid the params nesting by specifying <tt>:input_html</tt>.
175
+ can avoid the params nesting by specifying `:input_html`.
148
176
 
149
177
  ```erb
150
178
  <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
@@ -159,13 +187,13 @@ can avoid the params nesting by specifying <tt>:input_html</tt>.
159
187
 
160
188
  Next you'll need to let OmniAuth know what action to call when a registration
161
189
  fails. In your OmniAuth configuration, specify any valid rack endpoint in the
162
- <tt>:on_failed_registration</tt> option.
190
+ `:on_failed_registration` option.
163
191
 
164
192
  ```ruby
165
193
  use OmniAuth::Builder do
166
194
  provider :identity,
167
- :fields => [:email],
168
- :on_failed_registration => UsersController.action(:new)
195
+ fields: [:email],
196
+ on_failed_registration: UsersController.action(:new)
169
197
  end
170
198
  ```
171
199
 
@@ -182,15 +210,19 @@ within a particular subdomain. To do so, add :locate_conditions to your config.
182
210
  The default value is:
183
211
 
184
212
  ```ruby
185
- :locate_conditions => lambda { |req| { model.auth_key => req['auth_key']} }
213
+ use OmniAuth::Builder do
214
+ provider :identity,
215
+ locate_conditions: ->(req) { { model.auth_key => req['auth_key'] } }
216
+ # ...
217
+ end
186
218
  ```
187
219
 
188
- locate_conditions takes a Proc object, and must return a hash. The resulting hash is used
189
- as a parameter in the locate method for your ORM. The proc is evaluated in the
190
- callback context, and has access to the Identity model (using `model`) and receives the request
191
- object as a parameter. Note that model.auth_key defaults to 'email', but is also configurable.
220
+ `locate_conditions` takes a `Proc` object, and must return a `Hash` object, which will be used
221
+ as the argument to the locate method for your ORM. The proc is evaluated in the
222
+ callback context, and has access to your `Identity` model (using `model`) and receives the request
223
+ object as a parameter. Note that `model.auth_key` defaults to `email`, but is also configurable.
192
224
 
193
- Note: Be careful when customizing locate_conditions. The best way to modify the conditions is
225
+ Note: Be careful when customizing `locate_conditions`. The best way to modify the conditions is
194
226
  to copy the default value, and then add to the hash. Removing the default condition will almost
195
227
  always break things!
196
228
 
@@ -200,5 +232,6 @@ MIT License. See LICENSE for details.
200
232
 
201
233
  ## Copyright
202
234
 
203
- Copyright (c) 2020- Andrew Roberts, and Jellybooks Ltd.
235
+ Copyright (c) 2021 OmniAuth-Identity Maintainers
236
+ Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
204
237
  Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Identity
3
- VERSION = '2.0.0'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end
@@ -11,7 +11,6 @@ module OmniAuth
11
11
  module Models
12
12
  autoload :ActiveRecord, 'omniauth/identity/models/active_record'
13
13
  autoload :Mongoid, 'omniauth/identity/models/mongoid'
14
- autoload :DataMapper, 'omniauth/identity/models/data_mapper'
15
14
  autoload :CouchPotatoModule, 'omniauth/identity/models/couch_potato'
16
15
  end
17
16
  end
@@ -28,6 +28,7 @@ module OmniAuth
28
28
  def authenticate(conditions, password)
29
29
  instance = locate(conditions)
30
30
  return false unless instance
31
+
31
32
  instance.authenticate(password)
32
33
  end
33
34
 
@@ -52,22 +53,20 @@ module OmniAuth
52
53
  raise NotImplementedError
53
54
  end
54
55
 
55
- SCHEMA_ATTRIBUTES = %w(name email nickname first_name last_name location description image phone)
56
+ SCHEMA_ATTRIBUTES = %w[name email nickname first_name last_name location description image phone]
56
57
  # A hash of as much of the standard OmniAuth schema as is stored
57
58
  # in this particular model. By default, this will call instance
58
59
  # methods for each of the attributes it needs in turn, ignoring
59
60
  # any for which `#respond_to?` is `false`.
60
61
  #
61
- # If `first_name`, `nickname`, and/or `last_name` is provided but
62
+ # If `first_name`, `nickname`, and/or `last_name` is provided but
62
63
  # `name` is not, it will be automatically calculated.
63
64
  #
64
65
  # @return [Hash] A string-keyed hash of user information.
65
66
  def info
66
- info = SCHEMA_ATTRIBUTES.inject({}) do |hash,attribute|
67
+ SCHEMA_ATTRIBUTES.each_with_object({}) do |attribute, hash|
67
68
  hash[attribute] = send(attribute) if respond_to?(attribute)
68
- hash
69
69
  end
70
- info
71
70
  end
72
71
 
73
72
  # An identifying string that must be globally unique to the
@@ -76,16 +75,17 @@ module OmniAuth
76
75
  # @return [String] An identifier string unique to this identity.
77
76
  def uid
78
77
  if respond_to?(:id)
79
- return nil if self.id.nil?
80
- self.id.to_s
78
+ return nil if id.nil?
79
+
80
+ id.to_s
81
81
  else
82
- raise NotImplementedError
82
+ raise NotImplementedError
83
83
  end
84
84
  end
85
85
 
86
86
  # Used to retrieve the user-supplied authentication key (e.g. a
87
87
  # username or email). Determined using the class method of the same name,
88
- # defaults to `:email`.
88
+ # defaults to `:email`.
89
89
  #
90
90
  # @return [String] An identifying string that will be entered by
91
91
  # users upon sign in.
@@ -12,10 +12,11 @@ module OmniAuth
12
12
 
13
13
  def self.auth_key=(key)
14
14
  super
15
- validates_uniqueness_of key, :case_sensitive => false
15
+ validates_uniqueness_of key, case_sensitive: false
16
16
  end
17
17
 
18
18
  def self.locate(search_hash)
19
+ search_hash = search_hash.reverse_merge!('provider' => 'identity') if column_names.include?('provider')
19
20
  where(search_hash).first
20
21
  end
21
22
  end
@@ -5,11 +5,8 @@ module OmniAuth
5
5
  module Models
6
6
  # can not be named CouchPotato since there is a class with that name
7
7
  module CouchPotatoModule
8
-
9
8
  def self.included(base)
10
-
11
9
  base.class_eval do
12
-
13
10
  include ::OmniAuth::Identity::Model
14
11
  include ::OmniAuth::Identity::SecurePassword
15
12
 
@@ -17,7 +14,7 @@ module OmniAuth
17
14
 
18
15
  def self.auth_key=(key)
19
16
  super
20
- validates_uniqueness_of key, :case_sensitive => false
17
+ validates_uniqueness_of key, case_sensitive: false
21
18
  end
22
19
 
23
20
  def self.locate(search_hash)