omniauth-identity 1.1.1 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Guardfile DELETED
@@ -1,10 +0,0 @@
1
- guard 'rspec', :version => 2 do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
5
- end
6
-
7
- guard 'bundler' do
8
- watch('Gemfile')
9
- watch(/^.+\.gemspec/)
10
- end
data/README.markdown DELETED
@@ -1,202 +0,0 @@
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
- ## Usage
10
-
11
- This can be a bit hard to understand the first time. Luckily, Ryan Bates made
12
- a [Railscast](http://railscasts.com/episodes/304-omniauth-identity) about it!
13
-
14
- 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:
17
-
18
- ```ruby
19
- use OmniAuth::Builder do
20
- provider :identity, :fields => [:email]
21
- end
22
- ```
23
-
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.
27
-
28
- **Note:** OmniAuth Identity is different from many other user authentication
29
- systems in that it is *not* built to store authentication information in your primary
30
- `User` model. Instead, the `Identity` model should be **associated** with your
31
- `User` model giving you maximum flexibility to include other authentication
32
- strategies such as Facebook, Twitter, etc.
33
-
34
- ### ActiveRecord
35
-
36
- Just subclass `OmniAuth::Identity::Models::ActiveRecord` and provide fields
37
- in the database for all of the fields you are using.
38
-
39
- ```ruby
40
- class Identity < OmniAuth::Identity::Models::ActiveRecord
41
- # Add whatever you like!
42
- end
43
- ```
44
-
45
- ### Mongoid
46
-
47
- Include the `OmniAuth::Identity::Models::Mongoid` mixin and specify
48
- fields that you will need.
49
-
50
- ```ruby
51
- class Identity
52
- include Mongoid::Document
53
- include OmniAuth::Identity::Models::Mongoid
54
-
55
- field :email, type: String
56
- field :name, type: String
57
- field :password_digest, type: String
58
- end
59
- ```
60
-
61
- ### MongoMapper
62
-
63
- Include the `OmniAuth::Identity::Models::MongoMapper` mixin and specify
64
- fields that you will need.
65
-
66
- ```ruby
67
- class Identity
68
- include MongoMapper::Document
69
- include OmniAuth::Identity::Models::MongoMapper
70
-
71
- key :email, String
72
- key :name, String
73
- key :password_digest, String
74
- end
75
- ```
76
-
77
- ### DataMapper
78
-
79
- Include the `OmniAuth::Identity::Models::DataMapper` mixin and specify
80
- fields that you will need.
81
-
82
- ```ruby
83
- class Identity
84
- include DataMapper::Resource
85
- include OmniAuth::Identity::Models::DataMapper
86
-
87
- property :id, Serial
88
- property :email, String
89
- property :password_digest, Text
90
-
91
- attr_accessor :password_confirmation
92
-
93
- end
94
- ```
95
-
96
- ### CouchPotato
97
-
98
- Include the `OmniAuth::Identity::Models::CouchPotatoModule` mixin and specify fields that you will need.
99
-
100
- ```ruby
101
- class Identity
102
- include CouchPotato::Persistence
103
- include OmniAuth::Identity::Models::CouchPotatoModule
104
-
105
- property :email
106
- property :password_digest
107
-
108
- def self.where search_hash
109
- CouchPotato.database.view Identity.by_email(:key => search_hash)
110
- end
111
-
112
- view :by_email, :key => :email
113
- end
114
- ```
115
-
116
- Once you've got an Identity persistence model and the strategy up and
117
- running, you can point users to `/auth/identity` and it will request
118
- that they log in or give them the opportunity to sign up for an account.
119
- Once they have authenticated with their identity, OmniAuth will call
120
- through to `/auth/identity/callback` with the same kinds of information
121
- it would had the user authenticated through an external provider.
122
- Simple!
123
-
124
- ## Custom Auth Model
125
-
126
- To use a class other than the default, specify the <tt>:model</tt> option to a
127
- different class.
128
-
129
- ```ruby
130
- use OmniAuth::Builder do
131
- provider :identity, :fields => [:email], :model => MyCustomClass
132
- end
133
- ```
134
-
135
- ## Customizing Registration Failure
136
-
137
- To use your own custom registration form, create a form that POSTs to
138
- '/auth/identity/register' with 'password', 'password_confirmation', and your
139
- other fields.
140
-
141
- ```erb
142
- <%= form_tag '/auth/identity/register' do |f| %>
143
- <h1>Create an Account</h1>
144
- <%= text_field_tag :email %>
145
- <%= password_field_tag :password %>
146
- <%= password_field_tag :password_confirmation %>
147
- <%= submit_tag %>
148
- <% end %>
149
- ```
150
-
151
- Beware not to nest your form parameters within a namespace. This strategy
152
- looks for the form parameters at the top level of the post params. If you are
153
- using [simple\_form](https://github.com/plataformatec/simple_form), then you
154
- can avoid the params nesting by specifying <tt>:input_html</tt>.
155
-
156
- ```erb
157
- <%= simple_form_for @identity, :url => '/auth/identity/register' do |f| %>
158
- <h1>Create an Account</h1>
159
- <%# specify :input_html to avoid params nesting %>
160
- <%= f.input :email, :input_html => {:name => 'email'} %>
161
- <%= f.input :password, :as => 'password', :input_html => {:name => 'password'} %>
162
- <%= f.input :password_confirmation, :label => "Confirm Password", :as => 'password', :input_html => {:name => 'password_confirmation'} %>
163
- <button type='submit'>Sign Up</button>
164
- <% end %>
165
- ```
166
-
167
- Next you'll need to let OmniAuth know what action to call when a registration
168
- fails. In your OmniAuth configuration, specify any valid rack endpoint in the
169
- <tt>:on_failed_registration</tt> option.
170
-
171
- ```ruby
172
- use OmniAuth::Builder do
173
- provider :identity,
174
- :fields => [:email],
175
- :on_failed_registration => UsersController.action(:new)
176
- end
177
- ```
178
-
179
- For more information on rack endpoints, check out [this
180
- introduction](http://library.edgecase.com/Rails/2011/01/04/rails-routing-and-rack-endpoints.html)
181
- and
182
- [ActionController::Metal](http://rubydoc.info/docs/rails/ActionController/Metal)
183
-
184
- ## Customizing Locate Conditions
185
-
186
- You can customize the way that matching records are found when authenticating.
187
- For example, for a site with multiple domains, you may wish to scope the search
188
- within a particular subdomain. To do so, add :locate_conditions to your config.
189
- The default value is:
190
-
191
- ```ruby
192
- :locate_conditions => lambda { |req| { model.auth_key => req['auth_key']} }
193
- ```
194
-
195
- locate_conditions takes a Proc object, and must return a hash. The resulting hash is used
196
- as a parameter in the locate method for your ORM. The proc is evaluated in the
197
- callback context, and has access to the Identity model (using `model`) and receives the request
198
- object as a parameter. Note that model.auth_key defaults to 'email', but is also configurable.
199
-
200
- Note: Be careful when customizing locate_conditions. The best way to modify the conditions is
201
- to copy the default value, and then add to the hash. Removing the default condition will almost
202
- always break things!
data/Rakefile DELETED
@@ -1,9 +0,0 @@
1
- require 'bundler'
2
- Bundler::GemHelper.install_tasks
3
-
4
- require 'rspec/core/rake_task'
5
- desc "Run specs."
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task :default => :spec
9
- task :test => :spec
@@ -1,32 +0,0 @@
1
- require 'dm-core'
2
- require 'dm-validations'
3
-
4
- module OmniAuth
5
- module Identity
6
- module Models
7
- module DataMapper
8
- def self.included(base)
9
- base.class_eval do
10
- include OmniAuth::Identity::Model
11
- include OmniAuth::Identity::SecurePassword
12
-
13
- # http://api.rubyonrails.org/classes/ActiveRecord/Persistence.html#method-i-persisted-3F
14
- # http://rubydoc.info/github/mongoid/mongoid/master/Mongoid/State#persisted%3F-instance_method
15
- alias persisted? valid?
16
-
17
- has_secure_password
18
-
19
- def self.auth_key=(key)
20
- super
21
- validates_uniqueness_of :key
22
- end
23
-
24
- def self.locate(search_hash)
25
- all(search_hash).first
26
- end
27
- end
28
- end
29
- end # DataMapper
30
- end
31
- end
32
- end
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.dirname(__FILE__) + '/lib/omniauth-identity/version'
3
-
4
- Gem::Specification.new do |gem|
5
- gem.add_runtime_dependency 'omniauth', '~> 1.0'
6
- gem.add_runtime_dependency 'bcrypt-ruby', '~> 3.0'
7
-
8
- gem.add_development_dependency 'maruku', '~> 0.6'
9
- gem.add_development_dependency 'simplecov', '~> 0.4'
10
- gem.add_development_dependency 'rack-test', '~> 0.5'
11
- gem.add_development_dependency 'rake', '~> 0.8'
12
- gem.add_development_dependency 'rspec', '~> 2.7'
13
- gem.add_development_dependency 'activerecord', '~> 3.1'
14
- gem.add_development_dependency 'mongoid'
15
- gem.add_development_dependency 'mongo_mapper'
16
- gem.add_development_dependency 'datamapper'
17
- gem.add_development_dependency 'bson_ext'
18
- gem.add_development_dependency 'couch_potato'
19
-
20
- gem.name = 'omniauth-identity'
21
- gem.version = OmniAuth::Identity::VERSION
22
- gem.description = %q{Internal authentication handlers for OmniAuth.}
23
- gem.summary = gem.description
24
- gem.email = ['michael@intridea.com']
25
- gem.homepage = 'http://github.com/intridea/omniauth-identity'
26
- gem.authors = ['Michael Bleigh']
27
- gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
28
- gem.files = `git ls-files`.split("\n")
29
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
30
- gem.require_paths = ['lib']
31
- gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
32
- end
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe(OmniAuth::Identity::Models::DataMapper, :db => true) do
4
- class DataMapperTestIdentity
5
- include DataMapper::Resource
6
- include OmniAuth::Identity::Models::DataMapper
7
-
8
- property :id, Serial
9
- auth_key :ham_sandwich
10
- end
11
-
12
- DataMapper.finalize
13
-
14
- before :all do
15
- @resource = DataMapperTestIdentity.new
16
- end
17
-
18
- it 'should delegate locate to the all query method' do
19
- DataMapperTestIdentity.should_receive(:all).with('ham_sandwich' => 'open faced', 'category' => 'sandwiches').and_return(['wakka'])
20
- DataMapperTestIdentity.locate('ham_sandwich' => 'open faced', 'category' => 'sandwiches').should == 'wakka'
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe(OmniAuth::Identity::Models::MongoMapper, :db => true) do
4
- class MongoMapperTestIdentity
5
- include MongoMapper::Document
6
- include OmniAuth::Identity::Models::MongoMapper
7
- auth_key :ham_sandwich
8
- end
9
-
10
-
11
- it 'should delegate locate to the where query method' do
12
- MongoMapperTestIdentity.should_receive(:where).with('ham_sandwich' => 'open faced', 'category' => 'sandwiches').and_return(['wakka'])
13
- MongoMapperTestIdentity.locate('ham_sandwich' => 'open faced', 'category' => 'sandwiches').should == 'wakka'
14
- end
15
- end