Class: Warden::OpenID::Strategy

Inherits:
Strategies::Base
  • Object
show all
Defined in:
lib/warden/openid.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/warden/openid.rb', line 54

def authenticate!
  if response = env[Rack::OpenID::RESPONSE]
    case response.status
    when :success
      if user = Warden::OpenID.config.find_user(response)
        success!(user)
      else
        fail!('User not found')
        throw(:warden, :openid => {:response => response})
      end
    else
      fail!(response.respond_to?(:message) ? response.message : "OpenID authentication failed: #{response.status}")
    end
  elsif identifier = params['openid_identifier']
    if identifier.nil? || identifier.empty?
      fail!('OpenID identifier is required')
    else
       custom!([401, {'WWW-Authenticate' => Rack::OpenID.build_header(Warden::OpenID.config.to_params.merge(:identifier => identifier))}, ''])
    end
  end
end