Skip to content

Commit

Permalink
Addition of post-run block for extensibility
Browse files Browse the repository at this point in the history
darcs-hash:20071118045433-f4dbf-8c13ffcd8214f9032185703c12790f0fff8fc921.gz
  • Loading branch information
scytrin committed Nov 18, 2007
1 parent de56ae2 commit 596d395
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/rack/auth/openid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class OpenID < AbstractHandler
# A Hash of options is taken as it's single initializing argument. String
# keys are taken to be openid protocol extension namespaces. For example:
# 'sreg' => { 'required' => 'nickname' }
# If you wish, you may pass a block to OpenID.new, which will be called just
# before a response is returned. The passed arguments are the OpenID app's
# normal status, header, and body, as well as the openid object generated
# during handling. The returned value should be normal Rack
# [status,header,body].
#
# Other keys are taken as options for Rack::Auth::OpenID, normally Symbols.
# Only :return is required. :trust is highly recommended to be set.
Expand All @@ -37,11 +42,13 @@ class OpenID < AbstractHandler
# into. (ex: 'http://mysite.com/')
# * :session_key defines the key to the session hash in the env.
# (by default it uses 'rack.session')
def initialize options={}
def initialize options={}, &block
raise 'No return url provided.' unless options[:return]
warn 'No trust url provided.' unless options[:trust]
options[:trust] ||= options[:return]

@followup = block || proc{|r|r[0..2]}

@options = {
:session_key => 'rack.session'
}.merge(options)
Expand All @@ -57,6 +64,7 @@ def call env
else
bad_request
end
@followup.call(resp)
end

def check session, oid_url, request=nil
Expand Down

0 comments on commit 596d395

Please sign in to comment.