stormpath-omniauth 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Stormpath OmniAuth Strategy
2
+
3
+ Stormpath is the first easy, secure user management and authentication service
4
+ for developers. This is an OmniAuth strategy that will integrate with Stormpath.
5
+
6
+ ## Quickstart Guide
7
+
8
+ 1. From the root of the repo, navigate to the dummy directory and execute the
9
+ following Rake tasks:
10
+
11
+ ```sh
12
+ cd spec/dummy
13
+ rake db:migrate
14
+ rake db:test:prepare
15
+ ```
16
+
17
+ 1. You should then be able to run the full suite of specs from the root of the
18
+ repo, like so:
19
+
20
+ ```sh
21
+ rake spec
22
+ ```
23
+
24
+ ## Required Configuration Options
25
+
26
+ In order to use the Stormpath OmniAuth Strategy, three configuration options
27
+ must be specified. These options can be passed in a hash (second parameter of
28
+ the Strategy constructor), or (more commonly) set up by Rack during the "setup"
29
+ phase.
30
+
31
+ With Rack:
32
+
33
+ ```ruby
34
+ Rails.application.config.middleware.use OmniAuth::Builder do
35
+ provider :stormpath, :setup => lambda { |env|
36
+ env['omniauth.strategy'].options[:auth_redirect] = '/session/new'
37
+ env['omniauth.strategy'].options[:authenticator_class] = ::User
38
+ env['omniauth.strategy'].options[:obtain_uid] = Proc.new { |o| o.stormpath_url }
39
+ }
40
+ end
41
+ ```
42
+
43
+ A quick explanation of the three required options:
44
+
45
+ ### auth_redirect
46
+
47
+ Where to redirect the browser in order to display a form that will collect
48
+ login information.
49
+
50
+ ### authenticator_class
51
+
52
+ A class who will implement a method "authenticate" and return an object
53
+ representation (or superset) of a Stormpath Account. If you're using
54
+ stormpath-rails, this will be the class that's included the
55
+ Stormpath::Rails::Account module (::User, in this project's sample app).
56
+
57
+ ### obtain_uid
58
+
59
+ A method invoked on the object returned from the "authenticate" method which
60
+ returns a value that OmniAuth uses to uniquely identify a user in your system.
61
+ If you're using stormpath-rails, this will look something like:
62
+
63
+ ```ruby
64
+ obtain_uid = Proc.new { |obj| obj.stormpath_url }
65
+ ```
66
+
67
+ If your application is not storing any Stormpath data in a local database and
68
+ your authenticate method returned an instance of Stormpath::Resource::Account,
69
+ then this method could look like:
70
+
71
+ ```ruby
72
+ obtain_uid = Proc.new { |account| account.href }
73
+ ```
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'StormpathOmniauth'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ require "rspec/core/rake_task"
24
+
25
+ RSpec::Core::RakeTask.new
26
+
27
+ task :default => :spec
28
+ task :test => :spec
29
+
30
+
31
+ Bundler::GemHelper.install_tasks
32
+
@@ -0,0 +1,40 @@
1
+ require 'stormpath-sdk'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Stormpath
6
+ include OmniAuth::Strategy
7
+
8
+ option :login_field, :email_or_username
9
+ option :password_field, :password
10
+ option :stormpath_application, nil
11
+
12
+ def callback_phase
13
+ raise 'missing stormpath_application' unless options[:stormpath_application]
14
+
15
+ begin
16
+ login_request = ::Stormpath::Authentication::UsernamePasswordRequest.new(login, password)
17
+ auth_result = options[:stormpath_application].authenticate_account(login_request)
18
+ @account = auth_result.account
19
+ rescue
20
+ return fail!(:invalid_credentials)
21
+ end
22
+
23
+ super
24
+ end
25
+
26
+ def login
27
+ request[options[:login_field].to_s]
28
+ end
29
+
30
+ def password
31
+ request[options[:password_field].to_s]
32
+ end
33
+
34
+ uid do
35
+ @account.href
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module StormpathOmniauth
2
+ VERSION = "1.0.0.beta"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'omniauth'
2
+ require 'stormpath-omniauth/version'
3
+ require 'omniauth/strategies/stormpath'
metadata ADDED
@@ -0,0 +1,292 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stormpath-omniauth
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.beta
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Boram Yoon
9
+ - Erin Swenson-Healey
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-06-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bcrypt-ruby
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: '3.0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: omniauth
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ~>
37
+ - !ruby/object:Gem::Version
38
+ version: '1.0'
39
+ type: :runtime
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: stormpath-sdk
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.0.beta
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0.beta
63
+ - !ruby/object:Gem::Dependency
64
+ name: capybara
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ~>
69
+ - !ruby/object:Gem::Version
70
+ version: 1.1.2
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.1.2
79
+ - !ruby/object:Gem::Dependency
80
+ name: guard-rspec
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: guard-spork
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: jquery-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ - !ruby/object:Gem::Dependency
128
+ name: pry
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ - !ruby/object:Gem::Dependency
144
+ name: pry-debugger
145
+ requirement: !ruby/object:Gem::Requirement
146
+ none: false
147
+ requirements:
148
+ - - ! '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ type: :development
152
+ prerelease: false
153
+ version_requirements: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ - !ruby/object:Gem::Dependency
160
+ name: rails
161
+ requirement: !ruby/object:Gem::Requirement
162
+ none: false
163
+ requirements:
164
+ - - ~>
165
+ - !ruby/object:Gem::Version
166
+ version: 3.2.1
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ none: false
171
+ requirements:
172
+ - - ~>
173
+ - !ruby/object:Gem::Version
174
+ version: 3.2.1
175
+ - !ruby/object:Gem::Dependency
176
+ name: rspec-rails
177
+ requirement: !ruby/object:Gem::Requirement
178
+ none: false
179
+ requirements:
180
+ - - ! '>='
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ type: :development
184
+ prerelease: false
185
+ version_requirements: !ruby/object:Gem::Requirement
186
+ none: false
187
+ requirements:
188
+ - - ! '>='
189
+ - !ruby/object:Gem::Version
190
+ version: '0'
191
+ - !ruby/object:Gem::Dependency
192
+ name: sqlite3
193
+ requirement: !ruby/object:Gem::Requirement
194
+ none: false
195
+ requirements:
196
+ - - ! '>='
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
199
+ type: :development
200
+ prerelease: false
201
+ version_requirements: !ruby/object:Gem::Requirement
202
+ none: false
203
+ requirements:
204
+ - - ! '>='
205
+ - !ruby/object:Gem::Version
206
+ version: '0'
207
+ - !ruby/object:Gem::Dependency
208
+ name: stormpath-rails
209
+ requirement: !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ! '>='
213
+ - !ruby/object:Gem::Version
214
+ version: '0'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ none: false
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: vcr
225
+ requirement: !ruby/object:Gem::Requirement
226
+ none: false
227
+ requirements:
228
+ - - ! '>='
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
231
+ type: :development
232
+ prerelease: false
233
+ version_requirements: !ruby/object:Gem::Requirement
234
+ none: false
235
+ requirements:
236
+ - - ! '>='
237
+ - !ruby/object:Gem::Version
238
+ version: '0'
239
+ - !ruby/object:Gem::Dependency
240
+ name: webmock
241
+ requirement: !ruby/object:Gem::Requirement
242
+ none: false
243
+ requirements:
244
+ - - ! '>='
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ type: :development
248
+ prerelease: false
249
+ version_requirements: !ruby/object:Gem::Requirement
250
+ none: false
251
+ requirements:
252
+ - - ! '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ description: An OmniAuth strategy for use with Stormpath
256
+ email:
257
+ - boram@carbonfive.com
258
+ - erin@carbonfive.com
259
+ executables: []
260
+ extensions: []
261
+ extra_rdoc_files: []
262
+ files:
263
+ - lib/omniauth/strategies/stormpath.rb
264
+ - lib/stormpath-omniauth/version.rb
265
+ - lib/stormpath-omniauth.rb
266
+ - Rakefile
267
+ - README.md
268
+ homepage: https://github.com/stormpath/stormpath-omniauth
269
+ licenses: []
270
+ post_install_message:
271
+ rdoc_options: []
272
+ require_paths:
273
+ - lib
274
+ required_ruby_version: !ruby/object:Gem::Requirement
275
+ none: false
276
+ requirements:
277
+ - - ! '>='
278
+ - !ruby/object:Gem::Version
279
+ version: '0'
280
+ required_rubygems_version: !ruby/object:Gem::Requirement
281
+ none: false
282
+ requirements:
283
+ - - ! '>'
284
+ - !ruby/object:Gem::Version
285
+ version: 1.3.1
286
+ requirements: []
287
+ rubyforge_project:
288
+ rubygems_version: 1.8.25
289
+ signing_key:
290
+ specification_version: 3
291
+ summary: An OmniAuth strategy for use with Stormpath
292
+ test_files: []