omniauth-identity 1.1.0 → 3.0.2

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: 8e337a130887896ec09b2aa2a66fa1064a87b5aad59d1e068d484a2d2666f691
4
+ data.tar.gz: 7cdf49c8f0dc5db0d481233c91f9800932880d243f2c8311dc9336d3830d1296
5
+ SHA512:
6
+ metadata.gz: 83e043a28067c4e22ce4be6932901eea262846000623626e73f9b6efa3ee2cd8a63263d93240d81173533d8db4e3a86815bf653814b26ced28b16b29e4787762
7
+ data.tar.gz: b12161b52c4d4f3b2d5e19d954ad965f0a7c73d4622a50f8004c2659ccd06445f19e20db23c81926f3ff9dc74930739f3f31d69c4da351e1208ea055832700a6
data/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
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
+ ## [3.0.2] - 2021-02-14
12
+
13
+ ### Fixed
14
+
15
+ - Github Actions CI Build for Ruby 2.4, 3.0 and ruby-head
16
+ - Updated copyright
17
+ - Code style cleanup
18
+ - Added Code Climate "Quality"
19
+ - Updated Readme
20
+
21
+ ## [3.0.1] - 2021-02-14
22
+
23
+ ### Fixed
24
+
25
+ - Github Actions CI Build for various Rubies
26
+
27
+ ## [3.0] - 2021-02-13
28
+
29
+ ### Added
30
+
31
+ - Compatibility with Ruby 3
32
+ - Add option `:enable_login` to bypass OmniAuth disabling of GET method (default `true`)
33
+ - NOTE: This restores compatibility between this gem and the current, core, omniauth gem!
34
+ - README updates, including a rename to README.md
35
+ - CODE_OF_CONDUCT.md using v2
36
+ - Rubocop
37
+ - Github Actions for Continuous Integration
38
+ - Minimum Ruby version = 2.4
39
+ - Automatically adds "provider" => "identity" when "provider" column is detected
40
+ - Documentation in README.md
41
+
42
+ ### Removed
43
+
44
+ - Support for Rubies < 2.4
45
+ - Support for DataMapper, which died long ago.
46
+ - Unwanted git artifacts
47
+
48
+ ## [2.0] - 2020-09-01
49
+
50
+ ### Added
51
+
52
+ - CHANGELOG to maintain a history of changes.
53
+ - Include mongoid-rspec gem.
54
+
55
+ ### Changed
56
+
57
+ - Fix failing Specs
58
+ - Update Spec syntax to RSpec 3
59
+ - Fix deprecation Warnings
60
+ - Updated mongoid_spec.rb to leverage mongoid-rspec features.
61
+ - Fix security warning about missing secret in session cookie.
62
+ - 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+)
63
+ - Updated copyright information.
64
+ - Updated MongoMapper section of README to reflect its discontinued support.
65
+
66
+ ### Removed
67
+ - Gemfile.lock file
68
+ - 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,22 @@
1
+ Copyright (c) 2021 OmniAuth-Identity Maintainers
2
+ Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
3
+ Copyright (c) 2010-2015 Michael Bleigh and Intridea, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # OmniAuth Identity
2
+
3
+ [![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)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/maintainability)](https://codeclimate.com/github/omniauth/omniauth-identity/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/621d6211cb2e0959ce00/test_coverage)](https://codeclimate.com/github/omniauth/omniauth-identity/test_coverage)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
7
+ [![Open Source Helpers](https://www.codetriage.com/omniauth/omniauth-identity/badges/users.svg)](https://www.codetriage.com/omniauth/omniauth-identity)
8
+ [![Downloads Rank](https://img.shields.io/gem/rd/omniauth-identity.svg)](https://rubygems.org/gems/omniauth-identity)
9
+
10
+ The OmniAuth Identity gem provides a way for applications to utilize a
11
+ traditional login/password based authentication system without the need
12
+ to give up the simple authentication flow provided by OmniAuth. Identity
13
+ is designed on purpose to be as featureless as possible: it provides the
14
+ basic construct for user management and then gets out of the way.
15
+
16
+ ## Compatibility
17
+
18
+ This gem is compatible with, as of Feb 2021, version 3:
19
+
20
+ * Latest released version of omniauth, v2.0.2
21
+ * Ruby 2.4, 2.5, 2.6, 2.7, 3.0, ruby-head
22
+
23
+ ## Installation
24
+
25
+ To acquire the latest release from RubyGems add the following to your `Gemfile`:
26
+
27
+ ```ruby
28
+ gem 'omniauth-identity'
29
+ ```
30
+
31
+ If the git repository has new commits not yet in an official release, simply specify the repo instead:
32
+
33
+ ```ruby
34
+ gem 'omniauth-identity', git: 'https://github.com/intridea/omniauth-identity.git'
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ This can be a bit hard to understand the first time. Luckily, Ryan Bates made
40
+ a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
41
+
42
+ You use `omniauth-identity` just like you would any other OmniAuth provider: as a
43
+ Rack middleware. In rails, this would be created by an initializer, such as
44
+ `config/initializers/omniauth.rb`. The basic setup for a email/password authentication would look something like this:
45
+
46
+ ```ruby
47
+ use OmniAuth::Builder do
48
+ provider :identity, #mandatory: tells OA that the Identity strategy is being used
49
+ model: Identity, # optional: specifies the name of the "Identity" model. Defaults to "Identity"
50
+ fields: %i[email custom1 custom2] # optional: list of custom fields that are in the model's table
51
+ end
52
+ ```
53
+
54
+ Next, you need to create a model (called `Identity` by default, or specified
55
+ with `:model` argument above) that will be able to persist the information
56
+ provided by the user. Luckily for you, there are pre-built models for popular
57
+ ORMs that make this dead simple.
58
+
59
+ **Note:** OmniAuth Identity is different from many other user authentication
60
+ systems in that it is *not* built to store authentication information in your primary
61
+ `User` model. Instead, the `Identity` model should be **associated** with your
62
+ `User` model giving you maximum flexibility to include other authentication
63
+ strategies such as Facebook, Twitter, etc.
64
+
65
+ ### ActiveRecord
66
+
67
+ Just subclass `OmniAuth::Identity::Models::ActiveRecord` and provide fields
68
+ in the database for all of the fields you are using.
69
+
70
+ ```ruby
71
+ class Identity < OmniAuth::Identity::Models::ActiveRecord
72
+ auth_key :email # optional: specifies the field within the model that will be used during the login process
73
+ # defaults to email, but may be username, uid, login, etc.
74
+
75
+ # Anything else you want!
76
+ end
77
+ ```
78
+
79
+ ### Mongoid
80
+
81
+ Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
82
+ fields that you will need.
83
+
84
+ ```ruby
85
+ class Identity
86
+ include Mongoid::Document
87
+ include OmniAuth::Identity::Models::Mongoid
88
+
89
+ field :email, type: String
90
+ field :name, type: String
91
+ field :password_digest, type: String
92
+ end
93
+ ```
94
+
95
+ ### MongoMapper
96
+
97
+ Unfortunately MongoMapper is **not supported** in `omniauth-identity` from >= v2.0 as a result of it
98
+ not being maintained for several years.
99
+
100
+ It wasn't possible to include Mongoid *and* MongoMapper due to incompatible gem version
101
+ requirements. Therefore precedence was given to Mongoid as it is significantly more
102
+ popular and actively maintained.
103
+
104
+ ### DataMapper
105
+
106
+ Include the `OmniAuth::Identity::Models::DataMapper` mixin and specify
107
+ fields that you will need.
108
+
109
+ ```ruby
110
+ class Identity
111
+ include DataMapper::Resource
112
+ include OmniAuth::Identity::Models::DataMapper
113
+
114
+ property :id, Serial
115
+ property :email, String
116
+ property :password_digest, Text
117
+
118
+ attr_accessor :password_confirmation
119
+ end
120
+ ```
121
+
122
+ ### CouchPotato
123
+
124
+ Include the `OmniAuth::Identity::Models::CouchPotatoModule` mixin and specify fields that you will need.
125
+
126
+ ```ruby
127
+ class Identity
128
+ include CouchPotato::Persistence
129
+ include OmniAuth::Identity::Models::CouchPotatoModule
130
+
131
+ property :email
132
+ property :password_digest
133
+
134
+ def self.where(search_hash)
135
+ CouchPotato.database.view(Identity.by_email(key: search_hash))
136
+ end
137
+
138
+ view :by_email, key: :email
139
+ end
140
+ ```
141
+
142
+ Once you've got an `Identity` persistence model and the strategy up and
143
+ running, you can point users to `/auth/identity` and it will request
144
+ that they log in or give them the opportunity to sign up for an account.
145
+ Once they have authenticated with their identity, OmniAuth will call
146
+ through to `/auth/identity/callback` with the same kinds of information
147
+ it would had the user authenticated through an external provider.
148
+ Simple!
149
+
150
+ ## Custom Auth Model
151
+
152
+ To use a class other than the default, specify the <tt>:model</tt> option to a
153
+ different class.
154
+
155
+ ```ruby
156
+ use OmniAuth::Builder do
157
+ provider :identity, fields: [:email], model: MyCustomClass
158
+ end
159
+ ```
160
+
161
+ NOTE: In the above example, `MyCustomClass` must have a class method called `auth_key` that returns
162
+ the default (`email`) or custom `auth_key` to use.
163
+
164
+ ## Customizing Registration Failure
165
+
166
+ To use your own custom registration form, create a form that POSTs to
167
+ `/auth/identity/register` with `password`, `password_confirmation`, and your
168
+ other fields.
169
+
170
+ ```erb
171
+ <%= form_tag '/auth/identity/register' do |f| %>
172
+ <h1>Create an Account</h1>
173
+ <%= text_field_tag :email %>
174
+ <%= password_field_tag :password %>
175
+ <%= password_field_tag :password_confirmation %>
176
+ <%= submit_tag %>
177
+ <% end %>
178
+ ```
179
+
180
+ Beware not to nest your form parameters within a namespace. This strategy
181
+ looks for the form parameters at the top level of the post params. If you are
182
+ using [simple\_form](https://github.com/plataformatec/simple_form), then you
183
+ can avoid the params nesting by specifying `:input_html`.
184
+
185
+ ```erb
186
+ <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
187
+ <h1>Create an Account</h1>
188
+ <%# specify :input_html to avoid params nesting %>
189
+ <%= f.input :email, :input_html => {:name => 'email'} %>
190
+ <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
191
+ <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
192
+ <button type='submit'>Sign Up</button>
193
+ <% end %>
194
+ ```
195
+
196
+ Next you'll need to let OmniAuth know what action to call when a registration
197
+ fails. In your OmniAuth configuration, specify any valid rack endpoint in the
198
+ `:on_failed_registration` option.
199
+
200
+ ```ruby
201
+ use OmniAuth::Builder do
202
+ provider :identity,
203
+ fields: [:email],
204
+ on_failed_registration: UsersController.action(:new)
205
+ end
206
+ ```
207
+
208
+ For more information on rack endpoints, check out [this
209
+ introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
210
+ and
211
+ [ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
212
+
213
+ ## Customizing Locate Conditions
214
+
215
+ You can customize the way that matching records are found when authenticating.
216
+ For example, for a site with multiple domains, you may wish to scope the search
217
+ within a particular subdomain. To do so, add :locate_conditions to your config.
218
+ The default value is:
219
+
220
+ ```ruby
221
+ use OmniAuth::Builder do
222
+ provider :identity,
223
+ locate_conditions: ->(req) { { model.auth_key => req['auth_key'] } }
224
+ # ...
225
+ end
226
+ ```
227
+
228
+ `locate_conditions` takes a `Proc` object, and must return a `Hash` object, which will be used
229
+ as the argument to the locate method for your ORM. The proc is evaluated in the
230
+ callback context, and has access to your `Identity` model (using `model`) and receives the request
231
+ object as a parameter. Note that `model.auth_key` defaults to `email`, but is also configurable.
232
+
233
+ Note: Be careful when customizing `locate_conditions`. The best way to modify the conditions is
234
+ to copy the default value, and then add to the hash. Removing the default condition will almost
235
+ always break things!
236
+
237
+ ## License
238
+
239
+ MIT License. See LICENSE for details.
240
+
241
+ ## Copyright
242
+
243
+ Copyright (c) 2021 OmniAuth-Identity Maintainers
244
+ Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
245
+ Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.