omniauth-identity 2.0.0 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +61 -1
- data/CODE_OF_CONDUCT.md +133 -0
- data/LICENSE +2 -1
- data/README.md +256 -0
- data/lib/omniauth-identity.rb +2 -0
- data/lib/omniauth-identity/version.rb +3 -1
- data/lib/omniauth/identity.rb +4 -1
- data/lib/omniauth/identity/model.rb +13 -11
- data/lib/omniauth/identity/models/active_record.rb +4 -1
- data/lib/omniauth/identity/models/couch_potato.rb +3 -4
- data/lib/omniauth/identity/models/mongoid.rb +3 -7
- data/lib/omniauth/identity/models/no_brainer.rb +30 -0
- data/lib/omniauth/identity/models/sequel.rb +37 -0
- data/lib/omniauth/identity/secure_password.rb +4 -4
- data/lib/omniauth/strategies/identity.rb +92 -39
- data/spec/omniauth/identity/model_spec.rb +36 -33
- data/spec/omniauth/identity/models/active_record_spec.rb +23 -9
- data/spec/omniauth/identity/models/couch_potato_spec.rb +13 -8
- data/spec/omniauth/identity/models/mongoid_spec.rb +16 -11
- data/spec/omniauth/identity/models/no_brainer_spec.rb +17 -0
- data/spec/omniauth/identity/models/sequel_spec.rb +23 -0
- data/spec/omniauth/identity/secure_password_spec.rb +10 -8
- data/spec/omniauth/strategies/identity_spec.rb +174 -61
- data/spec/spec_helper.rb +17 -8
- metadata +60 -97
- data/.gitignore +0 -6
- data/.rspec +0 -3
- data/Gemfile +0 -13
- data/Guardfile +0 -10
- data/README.markdown +0 -204
- data/Rakefile +0 -9
- data/lib/omniauth/identity/models/data_mapper.rb +0 -32
- data/omniauth-identity.gemspec +0 -32
- data/spec/omniauth/identity/models/data_mapper_spec.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5de20f544ddaf124fc1b80a0ea15d97d56572034cc985e72001e177c3da2c92
|
4
|
+
data.tar.gz: 21e59364dcba511bd658c7503b4dce12fb7c26e37b7f4bec3b05c91d0d1dd4c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef710bfa64cef76922f89e93ca4292c106bda7e61cb8a49133452227f65163d2c5be70fade9ecc8d973ce35281a812d837edffe27be24689b34646c48109b07a
|
7
|
+
data.tar.gz: 812f288ec96fb46afa30a61fc34caa85b4efbe8857b8fb6dbeaeab9b2c181124db8b8deea40ebbccedcfc8b78d4039dbcad609782d0955a36423e543ba293865
|
data/CHANGELOG.md
CHANGED
@@ -6,13 +6,73 @@ 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
|
+
## [3.0.4] - 2021-02-14
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Add support for [sequel ORM](http://sequel.jeremyevans.net/)
|
16
|
+
|
17
|
+
## [3.0.3] - 2021-02-14
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Add option `:on_validation`, which can be used to add a Captcha
|
22
|
+
- See [example here](https://github.com/omniauth/omniauth-identity/pull/86#issue-63225122)
|
23
|
+
- Add support for nobrainer, an ORM for RethinkDB
|
24
|
+
- Validation error message on invalid registration form submission
|
25
|
+
|
26
|
+
### Removed
|
27
|
+
|
28
|
+
- ruby-head build... simply too slow
|
29
|
+
|
30
|
+
## [3.0.2] - 2021-02-14
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
|
34
|
+
- Github Actions CI Build for Ruby 2.4, 3.0 and ruby-head
|
35
|
+
- Updated copyright
|
36
|
+
- Code style cleanup
|
37
|
+
- Added Code Climate "Quality"
|
38
|
+
- Updated Readme
|
39
|
+
|
40
|
+
## [3.0.1] - 2021-02-14
|
41
|
+
|
42
|
+
### Fixed
|
43
|
+
|
44
|
+
- Github Actions CI Build for various Rubies
|
45
|
+
|
46
|
+
## [3.0] - 2021-02-13
|
47
|
+
|
48
|
+
### Added
|
49
|
+
|
50
|
+
- Compatibility with Ruby 3
|
51
|
+
- Add option `:enable_login` to bypass OmniAuth disabling of GET method (default `true`)
|
52
|
+
- NOTE: This restores compatibility between this gem and the current, core, omniauth gem!
|
53
|
+
- README updates, including a rename to README.md
|
54
|
+
- CODE_OF_CONDUCT.md using v2
|
55
|
+
- Rubocop
|
56
|
+
- Github Actions for Continuous Integration
|
57
|
+
- Minimum Ruby version = 2.4
|
58
|
+
- Automatically adds "provider" => "identity" when "provider" column is detected
|
59
|
+
- Documentation in README.md
|
60
|
+
|
61
|
+
### Removed
|
62
|
+
|
63
|
+
- Support for Rubies < 2.4
|
64
|
+
- Support for DataMapper, which died long ago.
|
65
|
+
- Unwanted git artifacts
|
66
|
+
|
9
67
|
## [2.0] - 2020-09-01
|
10
68
|
|
11
|
-
### Added
|
69
|
+
### Added
|
70
|
+
|
12
71
|
- CHANGELOG to maintain a history of changes.
|
13
72
|
- Include mongoid-rspec gem.
|
14
73
|
|
15
74
|
### Changed
|
75
|
+
|
16
76
|
- Fix failing Specs
|
17
77
|
- Update Spec syntax to RSpec 3
|
18
78
|
- Fix deprecation Warnings
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -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
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2021 OmniAuth-Identity Maintainers
|
2
|
+
Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
|
2
3
|
Copyright (c) 2010-2015 Michael Bleigh and Intridea, Inc.
|
3
4
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
data/README.md
ADDED
@@ -0,0 +1,256 @@
|
|
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)
|
11
|
+
|
12
|
+
The OmniAuth Identity gem provides a way for applications to utilize a
|
13
|
+
traditional login/password based authentication system without the need
|
14
|
+
to give up the simple authentication flow provided by OmniAuth. Identity
|
15
|
+
is designed on purpose to be as featureless as possible: it provides the
|
16
|
+
basic construct for user management and then gets out of the way.
|
17
|
+
|
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
|
24
|
+
|
25
|
+
## Installation
|
26
|
+
|
27
|
+
To acquire the latest release from RubyGems add the following to your `Gemfile`:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
gem 'omniauth-identity'
|
31
|
+
```
|
32
|
+
|
33
|
+
If the git repository has new commits not yet in an official release, simply specify the repo instead:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
gem 'omniauth-identity', git: 'https://github.com/intridea/omniauth-identity.git'
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
This can be a bit hard to understand the first time. Luckily, Ryan Bates made
|
42
|
+
a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
|
43
|
+
|
44
|
+
You use `omniauth-identity` just like you would any other OmniAuth provider: as a
|
45
|
+
Rack middleware. In rails, this would be created by an initializer, such as
|
46
|
+
`config/initializers/omniauth.rb`. The basic setup for a email/password authentication would look something like this:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
use OmniAuth::Builder do
|
50
|
+
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
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
Next, you need to create a model (called `Identity` by default, or specified
|
57
|
+
with `:model` argument above) that will be able to persist the information
|
58
|
+
provided by the user. Luckily for you, there are pre-built models for popular
|
59
|
+
ORMs that make this dead simple.
|
60
|
+
|
61
|
+
Once you've got an `Identity` persistence model and the strategy up and
|
62
|
+
running, you can point users to `/auth/identity` and it will request
|
63
|
+
that they log in or give them the opportunity to sign up for an account.
|
64
|
+
Once they have authenticated with their identity, OmniAuth will call
|
65
|
+
through to `/auth/identity/callback` with the same kinds of information
|
66
|
+
it would had the user authenticated through an external provider.
|
67
|
+
|
68
|
+
**Note:** OmniAuth Identity is different from many other user authentication
|
69
|
+
systems in that it is *not* built to store authentication information in your primary
|
70
|
+
`User` model. Instead, the `Identity` model should be **associated** with your
|
71
|
+
`User` model giving you maximum flexibility to include other authentication
|
72
|
+
strategies such as Facebook, Twitter, etc.
|
73
|
+
|
74
|
+
### ActiveRecord
|
75
|
+
|
76
|
+
Just subclass `OmniAuth::Identity::Models::ActiveRecord` and provide fields
|
77
|
+
in the database for all of the fields you are using.
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
class Identity < OmniAuth::Identity::Models::ActiveRecord
|
81
|
+
auth_key :email # optional: specifies the field within the model that will be used during the login process
|
82
|
+
# defaults to email, but may be username, uid, login, etc.
|
83
|
+
|
84
|
+
# Anything else you want!
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
### Sequel
|
89
|
+
|
90
|
+
[Sequel](http://sequel.jeremyevans.net/) is an alternative to ActiveRecord.
|
91
|
+
|
92
|
+
Just include `OmniAuth::Identity::Models::Sequel` mixin, and specify
|
93
|
+
whatever else you will need.
|
94
|
+
|
95
|
+
```ruby
|
96
|
+
class SequelTestIdentity < Sequel::Model
|
97
|
+
include OmniAuth::Identity::Models::Sequel
|
98
|
+
auth_key :email
|
99
|
+
# whatever else you want!
|
100
|
+
end
|
101
|
+
```
|
102
|
+
|
103
|
+
|
104
|
+
### Mongoid
|
105
|
+
|
106
|
+
Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
|
107
|
+
fields that you will need.
|
108
|
+
|
109
|
+
```ruby
|
110
|
+
class Identity
|
111
|
+
include Mongoid::Document
|
112
|
+
include OmniAuth::Identity::Models::Mongoid
|
113
|
+
|
114
|
+
field :email, type: String
|
115
|
+
field :name, type: String
|
116
|
+
field :password_digest, type: String
|
117
|
+
end
|
118
|
+
```
|
119
|
+
|
120
|
+
### CouchPotato
|
121
|
+
|
122
|
+
Include the `OmniAuth::Identity::Models::CouchPotatoModule` mixin and specify
|
123
|
+
fields that you will need.
|
124
|
+
|
125
|
+
```ruby
|
126
|
+
class Identity
|
127
|
+
include CouchPotato::Persistence
|
128
|
+
include OmniAuth::Identity::Models::CouchPotatoModule
|
129
|
+
|
130
|
+
property :email
|
131
|
+
property :password_digest
|
132
|
+
|
133
|
+
def self.where(search_hash)
|
134
|
+
CouchPotato.database.view(Identity.by_email(key: search_hash))
|
135
|
+
end
|
136
|
+
|
137
|
+
view :by_email, key: :email
|
138
|
+
end
|
139
|
+
```
|
140
|
+
|
141
|
+
### NoBrainer
|
142
|
+
|
143
|
+
[NoBrainer](http://nobrainer.io/) is an ORM for [RethinkDB](https://rethinkdb.com/).
|
144
|
+
|
145
|
+
Include the `OmniAuth::Identity::Models::NoBrainer` mixin and specify
|
146
|
+
fields that you will need.
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
class Identity
|
150
|
+
include NoBrainer::Document
|
151
|
+
include OmniAuth::Identity::Models::NoBrainer
|
152
|
+
|
153
|
+
auth_key :email
|
154
|
+
end
|
155
|
+
```
|
156
|
+
|
157
|
+
### Ruby Object Mapper
|
158
|
+
|
159
|
+
Would love to add a mixin for the [Ruby Object Mapper (ROM)](https://rom-rb.org/) if anyone wants to work on it!
|
160
|
+
|
161
|
+
## Custom Auth Model
|
162
|
+
|
163
|
+
To use a class other than the default, specify the <tt>:model</tt> option to a
|
164
|
+
different class.
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
use OmniAuth::Builder do
|
168
|
+
provider :identity, fields: [:email], model: MyCustomClass
|
169
|
+
end
|
170
|
+
```
|
171
|
+
|
172
|
+
NOTE: In the above example, `MyCustomClass` must have a class method called `auth_key` that returns
|
173
|
+
the default (`email`) or custom `auth_key` to use.
|
174
|
+
|
175
|
+
## Customizing Registration Failure
|
176
|
+
|
177
|
+
To use your own custom registration form, create a form that POSTs to
|
178
|
+
`/auth/identity/register` with `password`, `password_confirmation`, and your
|
179
|
+
other fields.
|
180
|
+
|
181
|
+
```erb
|
182
|
+
<%= form_tag '/auth/identity/register' do |f| %>
|
183
|
+
<h1>Create an Account</h1>
|
184
|
+
<%= text_field_tag :email %>
|
185
|
+
<%= password_field_tag :password %>
|
186
|
+
<%= password_field_tag :password_confirmation %>
|
187
|
+
<%= submit_tag %>
|
188
|
+
<% end %>
|
189
|
+
```
|
190
|
+
|
191
|
+
Beware not to nest your form parameters within a namespace. This strategy
|
192
|
+
looks for the form parameters at the top level of the post params. If you are
|
193
|
+
using [simple\_form](https://github.com/plataformatec/simple_form), then you
|
194
|
+
can avoid the params nesting by specifying `:input_html`.
|
195
|
+
|
196
|
+
```erb
|
197
|
+
<%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
|
198
|
+
<h1>Create an Account</h1>
|
199
|
+
<%# specify :input_html to avoid params nesting %>
|
200
|
+
<%= f.input :email, :input_html => {:name => 'email'} %>
|
201
|
+
<%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
|
202
|
+
<%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
|
203
|
+
<button type='submit'>Sign Up</button>
|
204
|
+
<% end %>
|
205
|
+
```
|
206
|
+
|
207
|
+
Next you'll need to let OmniAuth know what action to call when a registration
|
208
|
+
fails. In your OmniAuth configuration, specify any valid rack endpoint in the
|
209
|
+
`:on_failed_registration` option.
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
use OmniAuth::Builder do
|
213
|
+
provider :identity,
|
214
|
+
fields: [:email],
|
215
|
+
on_failed_registration: UsersController.action(:new)
|
216
|
+
end
|
217
|
+
```
|
218
|
+
|
219
|
+
For more information on rack endpoints, check out [this
|
220
|
+
introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
|
221
|
+
and
|
222
|
+
[ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
|
223
|
+
|
224
|
+
## Customizing Locate Conditions
|
225
|
+
|
226
|
+
You can customize the way that matching records are found when authenticating.
|
227
|
+
For example, for a site with multiple domains, you may wish to scope the search
|
228
|
+
within a particular subdomain. To do so, add :locate_conditions to your config.
|
229
|
+
The default value is:
|
230
|
+
|
231
|
+
```ruby
|
232
|
+
use OmniAuth::Builder do
|
233
|
+
provider :identity,
|
234
|
+
locate_conditions: ->(req) { { model.auth_key => req['auth_key'] } }
|
235
|
+
# ...
|
236
|
+
end
|
237
|
+
```
|
238
|
+
|
239
|
+
`locate_conditions` takes a `Proc` object, and must return a `Hash` object, which will be used
|
240
|
+
as the argument to the locate method for your ORM. The proc is evaluated in the
|
241
|
+
callback context, and has access to your `Identity` model (using `model`) and receives the request
|
242
|
+
object as a parameter. Note that `model.auth_key` defaults to `email`, but is also configurable.
|
243
|
+
|
244
|
+
Note: Be careful when customizing `locate_conditions`. The best way to modify the conditions is
|
245
|
+
to copy the default value, and then add to the hash. Removing the default condition will almost
|
246
|
+
always break things!
|
247
|
+
|
248
|
+
## License
|
249
|
+
|
250
|
+
MIT License. See LICENSE for details.
|
251
|
+
|
252
|
+
## Copyright
|
253
|
+
|
254
|
+
Copyright (c) 2021 OmniAuth-Identity Maintainers
|
255
|
+
Copyright (c) 2020 Peter Boling, Andrew Roberts, and Jellybooks Ltd.
|
256
|
+
Copyright (c) 2010-2015 Michael Bleigh, and Intridea, Inc.
|