omniauth-identity 1.0.0.rc2 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3f6fae0f25aadccc74594334c90cf581c141a7fb68cbe50f26638648aa0fbbe4
4
+ data.tar.gz: 6998b461e27a72cc4da0cd4ca80f63e284fbf9fbff466b40ec1df736e511516d
5
+ SHA512:
6
+ metadata.gz: e209c51695fef0b79d0b57360acb1f9dc464a0424f96e1ab87b9847c0de7350c677a057c7cedb7e587428465c6fb8eaefb53a644fae18b5a9c574d82a0fdaf86
7
+ data.tar.gz: 542dd3902564af08c6c6653b381ce545278ef759e0b0861df62a8e19a118cabf022143db267c81525a26e944679770f8e8b62c1a4f93282c55505bcc56442dd4
data/CHANGELOG.md ADDED
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+
6
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
7
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
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
+
20
+ ## [2.0] - 2020-09-01
21
+
22
+ ### Added
23
+ - CHANGELOG to maintain a history of changes.
24
+ - Include mongoid-rspec gem.
25
+
26
+ ### Changed
27
+ - Fix failing Specs
28
+ - Update Spec syntax to RSpec 3
29
+ - Fix deprecation Warnings
30
+ - Updated mongoid_spec.rb to leverage mongoid-rspec features.
31
+ - Fix security warning about missing secret in session cookie.
32
+ - Dependency version limits so that the most up-to-date gem dependencies are used. (rspec 3+, mongo 2+, mongoid 7+, rake 13+, rack 2+, json 2+)
33
+ - Updated copyright information.
34
+ - Updated MongoMapper section of README to reflect its discontinued support.
35
+
36
+ ### Removed
37
+ - Gemfile.lock file
38
+ - MongoMapper support; unable to satisfy dependencies of both MongoMapper and Mongoig now that MongoMapper is no longer actively maintained.
@@ -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
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2020- Andrew Roberts, and Jellybooks Ltd.
2
+ Copyright (c) 2010-2015 Michael Bleigh and Intridea, Inc.
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,237 @@
1
+ # OmniAuth Identity
2
+
3
+ The OmniAuth Identity gem provides a way for applications to utilize a
4
+ traditional login/password based authentication system without the need
5
+ to give up the simple authentication flow provided by OmniAuth. Identity
6
+ is designed on purpose to be as featureless as possible: it provides the
7
+ basic construct for user management and then gets out of the way.
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
+
29
+ ## Usage
30
+
31
+ This can be a bit hard to understand the first time. Luckily, Ryan Bates made
32
+ a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
33
+
34
+ You use `omniauth-identity` just like you would any other OmniAuth provider: as a
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:
37
+
38
+ ```ruby
39
+ use OmniAuth::Builder do
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
43
+ end
44
+ ```
45
+
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.
50
+
51
+ **Note:** OmniAuth Identity is different from many other user authentication
52
+ systems in that it is *not* built to store authentication information in your primary
53
+ `User` model. Instead, the `Identity` model should be **associated** with your
54
+ `User` model giving you maximum flexibility to include other authentication
55
+ strategies such as Facebook, Twitter, etc.
56
+
57
+ ### ActiveRecord
58
+
59
+ Just subclass `OmniAuth::Identity::Models::ActiveRecord` and provide fields
60
+ in the database for all of the fields you are using.
61
+
62
+ ```ruby
63
+ class Identity < OmniAuth::Identity::Models::ActiveRecord
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!
68
+ end
69
+ ```
70
+
71
+ ### Mongoid
72
+
73
+ Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
74
+ fields that you will need.
75
+
76
+ ```ruby
77
+ class Identity
78
+ include Mongoid::Document
79
+ include OmniAuth::Identity::Models::Mongoid
80
+
81
+ field :email, type: String
82
+ field :name, type: String
83
+ field :password_digest, type: String
84
+ end
85
+ ```
86
+
87
+ ### MongoMapper
88
+
89
+ Unfortunately MongoMapper is **not supported** in `omniauth-identity` from >= v2.0 as a result of it
90
+ not being maintained for several years.
91
+
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.
95
+
96
+ ### DataMapper
97
+
98
+ Include the `OmniAuth::Identity::Models::DataMapper` mixin and specify
99
+ fields that you will need.
100
+
101
+ ```ruby
102
+ class Identity
103
+ include DataMapper::Resource
104
+ include OmniAuth::Identity::Models::DataMapper
105
+
106
+ property :id, Serial
107
+ property :email, String
108
+ property :password_digest, Text
109
+
110
+ attr_accessor :password_confirmation
111
+ end
112
+ ```
113
+
114
+ ### CouchPotato
115
+
116
+ Include the `OmniAuth::Identity::Models::CouchPotatoModule` mixin and specify fields that you will need.
117
+
118
+ ```ruby
119
+ class Identity
120
+ include CouchPotato::Persistence
121
+ include OmniAuth::Identity::Models::CouchPotatoModule
122
+
123
+ property :email
124
+ property :password_digest
125
+
126
+ def self.where(search_hash)
127
+ CouchPotato.database.view(Identity.by_email(key: search_hash))
128
+ end
129
+
130
+ view :by_email, key: :email
131
+ end
132
+ ```
133
+
134
+ Once you've got an `Identity` persistence model and the strategy up and
135
+ running, you can point users to `/auth/identity` and it will request
136
+ that they log in or give them the opportunity to sign up for an account.
137
+ Once they have authenticated with their identity, OmniAuth will call
138
+ through to `/auth/identity/callback` with the same kinds of information
139
+ it would had the user authenticated through an external provider.
140
+ Simple!
141
+
142
+ ## Custom Auth Model
143
+
144
+ To use a class other than the default, specify the <tt>:model</tt> option to a
145
+ different class.
146
+
147
+ ```ruby
148
+ use OmniAuth::Builder do
149
+ provider :identity, fields: [:email], model: MyCustomClass
150
+ end
151
+ ```
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
+
156
+ ## Customizing Registration Failure
157
+
158
+ To use your own custom registration form, create a form that POSTs to
159
+ `/auth/identity/register` with `password`, `password_confirmation`, and your
160
+ other fields.
161
+
162
+ ```erb
163
+ <%= form_tag '/auth/identity/register' do |f| %>
164
+ <h1>Create an Account</h1>
165
+ <%= text_field_tag :email %>
166
+ <%= password_field_tag :password %>
167
+ <%= password_field_tag :password_confirmation %>
168
+ <%= submit_tag %>
169
+ <% end %>
170
+ ```
171
+
172
+ Beware not to nest your form parameters within a namespace. This strategy
173
+ looks for the form parameters at the top level of the post params. If you are
174
+ using [simple\_form](https://github.com/plataformatec/simple_form), then you
175
+ can avoid the params nesting by specifying `:input_html`.
176
+
177
+ ```erb
178
+ <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
179
+ <h1>Create an Account</h1>
180
+ <%# specify :input_html to avoid params nesting %>
181
+ <%= f.input :email, :input_html => {:name => 'email'} %>
182
+ <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
183
+ <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
184
+ <button type='submit'>Sign Up</button>
185
+ <% end %>
186
+ ```
187
+
188
+ Next you'll need to let OmniAuth know what action to call when a registration
189
+ fails. In your OmniAuth configuration, specify any valid rack endpoint in the
190
+ `:on_failed_registration` option.
191
+
192
+ ```ruby
193
+ use OmniAuth::Builder do
194
+ provider :identity,
195
+ fields: [:email],
196
+ on_failed_registration: UsersController.action(:new)
197
+ end
198
+ ```
199
+
200
+ For more information on rack endpoints, check out [this
201
+ introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
202
+ and
203
+ [ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
204
+
205
+ ## Customizing Locate Conditions
206
+
207
+ You can customize the way that matching records are found when authenticating.
208
+ For example, for a site with multiple domains, you may wish to scope the search
209
+ within a particular subdomain. To do so, add :locate_conditions to your config.
210
+ The default value is:
211
+
212
+ ```ruby
213
+ use OmniAuth::Builder do
214
+ provider :identity,
215
+ locate_conditions: ->(req) { { model.auth_key => req['auth_key'] } }
216
+ # ...
217
+ end
218
+ ```
219
+
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.
224
+
225
+ Note: Be careful when customizing `locate_conditions`. The best way to modify the conditions is
226
+ to copy the default value, and then add to the hash. Removing the default condition will almost
227
+ always break things!
228
+
229
+ ## License
230
+
231
+ MIT License. See LICENSE for details.
232
+
233
+ ## Copyright
234
+
235
+ Copyright (c) 2021 OmniAuth-Identity Maintainers
236
+ Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
237
+ Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Identity
3
- VERSION = '1.0.0.rc2'
3
+ VERSION = '3.0.0'
4
4
  end
5
5
  end