Class: Devise::Strategies::OpenidAuthenticatable

Inherits:
Authenticatable
  • Object
show all
Defined in:
lib/devise_openid_authenticatable/strategy.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/devise_openid_authenticatable/strategy.rb', line 9

def authenticate!
  logger.debug("Authenticating with OpenID for mapping #{mapping.to}")

  if provider_response
    handle_response!
  else # Delegate authentication to Rack::OpenID by throwing a 401
    opts = { :identifier => params[scope]["identity_url"], :return_to => return_url, :trust_root => trust_root, :method => 'post' }
    opts[:immediate] = true if params[scope]["immediate"]
    opts[:optional] = mapping.to.openid_optional_fields if mapping.to.respond_to?(:openid_optional_fields)
    opts[:required] = mapping.to.openid_required_fields if mapping.to.respond_to?(:openid_required_fields)
    custom! [401, { Rack::OpenID::AUTHENTICATE_HEADER => Rack::OpenID.build_header(opts) }, "Sign in with OpenID"]
  end
end

#store?Boolean

CSRF won’t be able to be verified on returning from the OpenID server, so we will bypass that check for this strategy

Returns:

  • (Boolean)


24
25
26
# File 'lib/devise_openid_authenticatable/strategy.rb', line 24

def store?
  true
end

#valid?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/devise_openid_authenticatable/strategy.rb', line 5

def valid?
  valid_mapping? && ( provider_response? || identity_param? )
end