chowder 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/chowder/openid.rb +33 -0
  2. data/lib/chowder.rb +0 -31
  3. metadata +3 -2
@@ -0,0 +1,33 @@
1
+ require 'openid'
2
+ require 'openid/store/filesystem'
3
+
4
+ module Chowder
5
+ class OpenID < Base
6
+ def host
7
+ host = env['HTTP_HOST'] || "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}"
8
+ "http://#{host}"
9
+ end
10
+
11
+ def setup_consumer
12
+ store = ::OpenID::Store::Filesystem.new('.openid')
13
+ osession = session[:openid] ||= {}
14
+ @consumer = ::OpenID::Consumer.new(osession, store)
15
+ end
16
+
17
+ post '/openid/initiate' do
18
+ setup_consumer
19
+ url = @consumer.begin(params['openid_identifier']).redirect_url(host, host + '/openid/authenticate')
20
+ redirect url
21
+ end
22
+
23
+ get '/openid/authenticate' do
24
+ setup_consumer
25
+ res = @consumer.complete(request.params, host + '/openid/authenticate')
26
+ user = @login_callback.call(res.identity_url)
27
+ if res.is_a?(::OpenID::Consumer::SuccessResponse) && authorize(user)
28
+ return_or_redirect_to '/'
29
+ end
30
+ redirect '/login'
31
+ end
32
+ end
33
+ end
data/lib/chowder.rb CHANGED
@@ -1,7 +1,5 @@
1
1
  require 'sinatra/base'
2
2
  require 'ostruct'
3
- require 'openid'
4
- require 'openid/store/filesystem'
5
3
 
6
4
  module Chowder
7
5
  class Base < Sinatra::Base
@@ -144,33 +142,4 @@ module Chowder
144
142
  )
145
143
  end
146
144
  end
147
-
148
- class OpenID < Base
149
- def host
150
- host = env['HTTP_HOST'] || "#{env['SERVER_NAME']}:#{env['SERVER_PORT']}"
151
- "http://#{host}"
152
- end
153
-
154
- def setup_consumer
155
- store = ::OpenID::Store::Filesystem.new('.openid')
156
- osession = session[:openid] ||= {}
157
- @consumer = ::OpenID::Consumer.new(osession, store)
158
- end
159
-
160
- post '/openid/initiate' do
161
- setup_consumer
162
- url = @consumer.begin(params['openid_identifier']).redirect_url(host, host + '/openid/authenticate')
163
- redirect url
164
- end
165
-
166
- get '/openid/authenticate' do
167
- setup_consumer
168
- res = @consumer.complete(request.params, host + '/openid/authenticate')
169
- user = @login_callback.call(res.identity_url)
170
- if res.is_a?(::OpenID::Consumer::SuccessResponse) && authorize(user)
171
- return_or_redirect_to '/'
172
- end
173
- redirect '/login'
174
- end
175
- end
176
145
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chowder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Vangberg
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-01-19 00:00:00 +01:00
13
+ date: 2009-01-30 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
 
34
34
  files:
35
35
  - lib/chowder.rb
36
+ - lib/chowder/openid.rb
36
37
  - lib/sinatra/chowder.rb
37
38
  - lib/chowder/rails.rb
38
39
  has_rdoc: true